Again, many thanks for the help!
I have not had much time to go into the problem too much lately. But I will, and hopefully soon. I did take a peek in the java script file and it does not contain absolute paths anywhere so I will try to change that.. will also look up the "chroot'd environment" thing =)
See ya!
Staffan
: : : Hi,
: : :
: : : : I've written a script that works perfectly when run from a shell but
: : : : not when running it from a homepage. One thing the script does is to
: : : : call a program with several parameters. That program creates a file
: : : : that my script later prints.
: : : : When I run the script via the web it's like the script ignores the
: : : : lines where it calls the extern program (because there is no created
: : : : file afterwards).
: : : :
: : : : Any suggestions?
: : : : I started learning Perl today so my experience is zero.. I tried to
: : : : google for a solution under a long time but with no results.
: : : :
: : : I doubt it ignores the line that calls the external program, but that the call just doesn't work. I suggest that you do some error checking; that is, if you do:-
: : :
: : : system('program');
: : :
: : : The change it to:-
: : :
: : : system('program') or print "ERROR: Can't run program: $!\n";
: : :
: : : So it reports the error. As for why the external program doesn't run, here are some things to consider...
: : :
: : : 1) Could it be a relative path issue, and the CWD of the script is different than it is at the shell? Try an absolute path, perhaps.
: : :
: : : 2) Could it be anything to do with permissions? What user does your script run as? Does that user have permission to run the external program?
: : :
: : : Hope this helps you track it down, or at least eliminate thing it isn't.
: : :
: : : Take care,
: : :
: : : Jonathan
: : :
: : : ###
: : : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
: : : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
: : : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
: : :
: : :
: : Thanks for the help!
: :
: : I changed the paths to absolute paths (I think all permissions were
: : set in a right way) and added the error report. Still some strange
: : stuff though..
: :
: : When I now run the script from an xterm the external program (which, I
: : noticed, also is a script) works/runs okay but afterwards the error
: : message "ERROR: Can't run program: $!\n" shows, the variable $!
: : contains nothing.
: :
: Argh...yes, I must have been thinking in Perl 6 mode when I wrote that. Sorry. The system() function is an oddity. The problem is that unlike most functions, which return 0 on failure (or more to the point, something that evaluates in boolean context to false), the system function returns 0 on success. So, just (and only) for system, you actually need to say:-
:
: system('program') and print "ERROR: Can't run program: $!\n";
:
: For almost all other functions you'd use "or" there instead of "and"...I completely forgot about this subtle difference with system.
:
: : Not sure exactly what that means; does the fact that $! is 'empty'
: : mean that it worked fine?
: : Or did something go wrong since the error message showed at all..?
: :
: Yeah, my brain went wrong. Try it again now. $! should contain the error when there actually is one.
:
: : Running the script via a homepage still doesn't work though, error
: : output in mozilla points to the absolute path of the external program
: : (script) and then these three lines:
: :
: : basename: command not found
: : dirname: command not found
: : java: command not found
: :
: : (The external script runs a java program..)
: :
: : I really have no clue about what this means, maybe it has nothing to
: : do with Perl..?
: :
: I get the nasty feeling this is going to take some working through. Those 3 messages are quite interesting, in that they claim certain commands cannot be found. This makes me thing two things. Firstly, the environment that your script runs in has a different path (or has other differences) to the one you have in the command line. A simple experiment would be to do this:-
:
: print "$_=$ENV{$_}\n" for sort keys %ENV;
:
: And see what the output in both the browser and at the command line is. There will be a lot of things that differ between them that don't matter, but certain things (like the path - e.g. where the system looks for stuff) could matter. Have you tried putting absoloute paths in the external scripts for java, e.g. /usr/bin/java, or wherever it is?
:
: The only other thing that comes to mind right now is that your script could be running in a chroot'd environment...
:
: Jonathan
:
: ###
: for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
: (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
: /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
:
: