Unfortunately this is probably not a brain teaser for you guys but i am stumped as a new perl user. The purpose is simple...to tell perl to go to a specified directory and unzip a specified file.
I have an html form that is executing a perl script. I am trying to use the html variables inside the perl. I can print them...so i know i am getting them inside the script...but when i use them in a command.. they dont work...if i hard code the text with the command they work. So i am assuming for some reason perl is not evaluating the variable as its contents when used in the script. What am i doing wrong?
Here is the html
<?php
//upload and unzip a package
//this file needs to be in adminstrator folder
//and the unzip.cgi needs to be in the cgi-bin folder
if(!isset($_POST['upload'])) {
echo " This program uploads a zip file via ftp to a server <br>";
echo " In a particular directory and then unzips it there <br>";
echo " Usage: dir = directory you want it in <br>";
echo " Example: /frog/dog/cat <br>";
echo " Usage: zip = the zip file you want uploaded and unzips <br
+>";
echo " Example: phpwcms_1.3.3.zip <br>";
echo '
<form name="upload" method="POST" action="http://mydomain.com/cg
+i-bin/undone.cgi">
dirname<input name=dir size=55> <br />
zipname<input name=zip size=55> <br />
<input type="submit" name="upload" value="Upload">
</form>
';
} else {
}
?>
Here is the perl
#!/usr/bin/perl -w
print "Content-type: text/plain\n\n";
use CGI;
my $query = new CGI;
my $dir = $query->param('dir');
my $zip = $query->param('zip');
## Here is the commands that wont work
cd $dir
unzip $zip
## Here i can print them...just fine
print $dir;
print $zip;
If i hardcode the values of dir and zip like this
cd /dog/cat and unzip rat.zip they work just fine...
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.