Re: Can't Get Command Line Unzipper to Execute in CGI/Perl Script
by ikegami (Patriarch) on Jun 24, 2009 at 23:41 UTC
|
I will put in the entire script here
Why?! Please post the minimum amount of code required to replicate the problem.
And why do you think it's a good idea to forgo adding error checking when something doesn't work?
Did you even check the error log for messages?
By the way, you messed up the readmore tags. They aren't part of your code.
| [reply] |
|
Thanks. I'm fixing the Readmore stuff. I tried to post the minimum with readmore. I did think it was a good idea to get rid of error checking. Sorry, I'm a newbie, I just want it to work first. I looked for the logs. Haven't found them yet. I will look again. That's probably the best place to look, thanks.
| [reply] |
|
Sorry, I'm a newbie, I just want it to work first.
This is a not uncommon, but utterly wrong-headed "newbie" notion.
Error checking, like the use strict and use warnings pragmas, is helpful in getting "it to work....", not some sort of add-on for use afterwards.
| [reply] [d/l] [select] |
Re: Can't Get Command Line Unzipper to Execute in CGI/Perl Script
by graff (Chancellor) on Jun 25, 2009 at 01:25 UTC
|
You said:
I'm trying to execute the unzipper from a command in a popular upload script.
And for some reason, that "unzipper" is named "no-frills.exe". Okay, fine. When I searched your code for "no-frills", I found this line (not quite half-way down, at line #464):
open my $wfh, "| no-frills.exe $uploadedfile";
Then I searched for "$wfh". Wouldn't you know... that variable name occurs only once in your 1K lines of code, at that very line #464. So, you open a pipeline file handle to write to this "unzipper" program, but you never write anything to the file handle -- at least, that's how it is in the posted code.
What would you expect to happen, given that the pipeline file handle receives no input?
BTW, while you're fixing that, you might also want to give the full path name to the program when opening the pipe -- there's no guarantee that the web server process knows where it is (has this program in its execution PATH). | [reply] [d/l] |
|
I tried to execute the unzipper with back ticks/quotes too and it didn't work.
`no-frills.exe $uploadedfile`;
I just want to unzip a file first. I have a lot more additional (also sloppy but it works) code to add but I can't proceed if I can't get the script to execute an unzip...
Thanks very much for the valuable suggestion to try the full path. We'll see if that helps.
| [reply] [d/l] |
|
system('no-frills.exe', $uploadedfile)
or die("no-frills: $?/$!\n");
Using the multi-argument form of system will help handle non-trivial file names.
Make sure the current work directory is what you expect it to be. | [reply] [d/l] |
Re: Can't Get Command Line Unzipper to Execute in CGI/Perl Script
by dreadpiratepeter (Priest) on Jun 25, 2009 at 00:14 UTC
|
| [reply] |
|
Pete, I am a newbie squared. The script is mostly canned stuff from a commercial vendor, not me. This exercise is for me and my purposes. Yes it would certainly be scary if I was providing this Perl script (at least my little part) as a service.
| [reply] |
|
| [reply] |
Re: Can't Get Command Line Unzipper to Execute in CGI/Perl Script
by ww (Archbishop) on Jun 25, 2009 at 04:20 UTC
|
Did the vendor authorize you to post this "copyright material" on PM (or anywhere else)? | [reply] |
|
Hmm...Maybe not. It's freeware but maybe not postable. How do I take it down?
| [reply] |
Re: Can't Get Command Line Unzipper to Execute in CGI/Perl Script
by Crackers2 (Parson) on Jun 25, 2009 at 13:42 UTC
|
From the 755 permissions you mention, it seems that you're on a unix-like system; yet the executable you mention ends in .exe, which is typically used for dos/windows executables.
Are you sure the executable is compatible with the OS on your host?
| [reply] |
|
Ahh! I think that's the answer. Sorry for being so dense to miss this one.
| [reply] |
Re: Can't Get Command Line Unzipper to Execute in CGI/Perl Script
by scorpio17 (Canon) on Jun 25, 2009 at 14:03 UTC
|
I would try creating a very simple test script, with the full path and filename hardcoded, etc, just to prove that the unzipper utility will do what you want.
Assuming that it turns out to be incompatible with the host's system, you're going to need to handle the unzipping yourself. Never fear, someone has already done all the hard work for you and put it on CPAN. I'd suggest trying IO::Uncompress::AnyInflate for simple gzip/zip type files.
| [reply] |
|
The reason I have been using no-frills.exe (based on Delphi Zip) and also CakeCmd.exe, is that they are tolerant of zip corruption. I am trying to unzip corrupt Word and Excel 2007 files, which are in a zipped state. I've tried zlib, it does not unzip corrupt docx and xlsx files even after using the repair function it has.
| [reply] |