PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Good morning... does anyone know(i am sure lots do) why the exec() statement?
the executable program displays a random image on refresh. I cannot get anything from it. Not even an error message if failed.
I even tryed PASSTHRU()... but with no use
Theis is teh text from teh manual but it does not seem to work... What am i doing wrong?????
What exactly is random.cgi returning?
-- a full <img > tag?, just the filename? etc.
Where is it being embeded into the result html stream? Has your code already started the body block of the document? Are you at a legal place for the img tag?
Exec returns the last line of the output of the program into a string, so you would have to echo/print the result of exec, and random.cgi would have to return the text desired as its last line of output. Passthru directly injects the called scripts output into the resulting html, are there any extra characters being outputted by random.cgi that may mess up the formatting?
Did you remove the <!-- --> comments surround the old shtml version? Is exec/passthru outputting the correct img tag, only for it to be commented out?
teh random image script simply creates a random number and access teh image name by that number. it is a simple script (See Below please)
The formating of the HTML is all in the right place so does the removal from teh <!--- ---> in SHTML. Even when i do teh echo to output teh result from teh EXEC(), it still does not give me anything..! (i,e <?echo exec ('./cgi-bin/random.cgi');?>
as you can see the last line is a print that should output teh image...
This is a total guess, but maybe the script needs to have an exit, placed after the printing and before the error function defination.
Have you checked for the safe_mode variables settings in your (or your hosts) php.ini file?
Specificly if safe_mode is on
you'll need to have the cgi-bin directoty of similar list in the safe_mode_exec_dir configuration setting.
This worked for me.
Possible problems, you script seems to be lacking the "#!/usr/bin/perl", (at least it looks like a perl script to me).
Is the script executable by the webserver?
yes... it si working when it is included as part of the index.SHTML.
But it does not work when i try to simulate teh same thing under PHP!
The #!/usr/bin/perl is included but i missed copying it....
This is puzelling. I tryed the same exact stuff that you had and i made sure that the pl script is in the right place and i called many different ways... but no use It gives me BFORE.. And AFTER and nothing in between. It must be something stupied that i am doing wrong... . Whats driving crazy is it works in teh SHTML file!
Sorry, I'm stumped then. hopefully someone else here will have some ideas on what to try.... You are giving a full path, right? My tests were failing when I used a relative path.