Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CGI Script unable to execute winrar 1

Status
Not open for further replies.

zephan

Programmer
Jan 14, 2002
217
A2
Hi All,
I have got to CGI scripts, one of them upload a file on a server, and the other one process the file then compress it with winrar in the same directory.

The first script works fine, and so does the second one when it is run from the server. But when it is from the browser (CGI) the second script does everything normal except that it does not generate the compressed file.

I thought it was a problem of access rights, but the first script manage to write a file in the directory.

What could it be, is there a pecial permission to run other programs.

I use Windwos 2003, IIS 5 with activestate Perl 5.6.


Thanks
 
How is the code executing WinRAR? There might be weird %PATH% issues when running as a CGI script so you'd need to use the full path to the exe.

Code:
my $bin = 'C:\Program Files\WinRAR\winrar.exe';
system(qq{"$bin" "$targetfile"});

Note also "$bin" is in quotes in the system command, because "Program Files" has a space in it and the command might be misinterpreted, thinking "C:\Program" is the binary and "Files\WinRAR\winrar.exe" is the first argument to it.

Post some of your code that deals with running this and we'll be able to see where the problem is.

Cuvou.com | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'
 
Yes. Morever it didn't work unless I put each command line argument and option between " "
Code:
my $bin = 'C:\Program Files\WinRAR\winrar.exe';
system(qq{"$bin" "A $sourcefile $targetfile"}); #A for Archive, didn't work this way
my $bin = 'C:\Program Files\WinRAR\winrar.exe';
system(qq{"$bin" "A" "$sourcefile" "$targetfile"});#this one is fine

Thank you guy
 
One other thing:

If you use the multi-argument form of system() you don't even need the quotes.

Code:
system ($bin, "A", $sourcefile, $targetfile);

Cuvou.com | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'
 
Thank you Kirsle, the issue was the blanks in the filepath and the security rights as you can guess.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top