|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Cgi - system command and redirecting
HI
I have a perl cgi that does everything i want, now im at the end of it and I want it to run a shell script and then redirect the user to another page. I have tried looking in the system and exec calls but can't get either to work and am not even sure which is the best one to use. If someone can provide me some simple syntax for how to execute a file that i would normally do like this: # ./myscriptname I would be most greatful. Once it runs myscript I then need the user to be redirected to a page example.htm I have tried print "location: path/to/example.htm"; but it only seems to work when put at the top of the cgi, this is no good as the cgi validates a form (it doesnt when you put this at the top) Alternatively to this the cgi could generate its own html... At the moment my script looks like this (excluding the usual stuff at the top) I need the things i detailed above to happen after the go subroutine. THanks ! |
|
#2
|
|||
|
|||
|
You could possibly try it using Javascript. Here is an example: http://www.w3schools.com/JS/tryit.asp?filename=tryjs_location
So you'd end up with something like this: |
|
#3
|
||||
|
||||
|
the location redirect will only work if it's the 'first' thing printed to the browser...
__________________
--Ax without exception, there is no rule ... The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones ![]() 09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0 Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. -- Jamie Zawinski |
|
#4
|
|||
|
|||
|
cheers for the replies. I have found a rather skanky way of doing it - generating my own html which then uses a meta refresh / redirect, but I may just generate my own html without redirecting as it doesn't need to be anything special.
now... Does anyone have any idea how i would run a shell script from within my cgi script. I think I want to use 'system' as it does it then returns back to the cgi to carry on. I don't need any output from the script - i just want it to run but I just cant get it to work. |
|
#5
|
||||
|
||||
|
what have you tried?
|
|
#6
|
|||
|
|||
|
Quote:
At the moment i have this line of code As far as I know there is nothing wrong with that and since my last post i have come to think it must be something to do with folder /file permissions. Firstly, should i chown myscript to apache? myscript also puts a file in to a different folder - /var/www/html/download - does the download folder need to be chowned to apache? I have write / execute permissions set for both so that shouldnt be a problem. |
|
#7
|
||||
|
||||
|
|
|
#8
|
|||
|
|||
|
Its a shell script not a perl script - do i still need to do that?
I noticed that you included $! and Thats given me a better error message "inappropriate ioctl for device" $? is giving me the error message 0 Is this because my shell script wants to print something to the terminal ? and to make things more complicated... my shell script calls another one which also wants to write things to the terminal.. HELP ! ![]() |
|
#9
|
||||
|
||||
|
have a wise look at your shell scripts and see how much is involved in porting them to perl, otherwise you'd need to enable permissions which wouldn't be a good idea
|
|
#10
|
|||
|
|||
|
I have put some of it in to perl but some of my stuff just had to stay in the shell script..
my error message disappeared and looking through my apache logs I found out there were also permissions problems so I chowned a few folders to apache and it now works. now to get stuck on the next bit ![]() |
|
#11
|
||||
|
||||
|
good stuff.
|