Cron job is not an option because the point is to execute these scripts whenever I want.
As far as I understand I cannot do this with PHP because I need root access or some kind of similar privilegies.
Is there any way I can do this using perl or any other way?
I mean, I want to execute these shell scripts via a web page.
Any input on this subject will help.
Thanks,
Enrique
Anyway, since I'm a web designer that can deal with php but very little or no Perl, I will need a further explanation.
$foo contains the variable enclosed within backticks, but how should I execute that command from the script?
Perhaps using SYSTEM or EXEC functions?
Or is it that just by assigning the command to that variable it executes instantly?
Thanks,
Enrique
That's it. You're basically telling Perl to set $foo to the result of the command in the backticks, so Perl spawns a shell, executes the command, sets $foo and closes the shell.
After that you can ignore $foo if you want - the command has been executed anyway.
With my limited programming knowledge (I'm not a programmer) I managed to create a couple simple one liners that performed some lightning fast data extraction from the server log files.
Since I don't have root access permisions, it seems that I will have to find a way of translating those one liners to perl or php.
Thanks again,
Enrique
You *may* be able to arrange permissions for a specific script using sudo [courtesan.com] - if you can persuade your server admin to set it up ;)
All apache does is executes the specified file in a separate shell process.
Be it
#!/usr/local/bin/perl
or
#!/bin/sh
or whatever you tell is to execute.
That first line tells the shell which interpreter command to use for a file (for all text files with execute bit set).
So set it to the shell of your choice and that's what will be executed.
Perl has SYSTEM too -- you may be more comfortable using that.
Here's my very stodgy subroutine for doing shell commands and reporting errors.
sub doSystem {
my $cmd = shift();
if (system($cmd) == 0 ) {
return 1
} else {
print "Error executing shell command: $cmd -- $!";
# Remove print line above once goes live?
return;
}
}