first attempt at perl (SEC: UNCLASSIFIED)

Kim Holburn kim.holburn at
Fri Apr 19 18:08:39 EST 2002

At 1:45 PM +1000 02/4/19, Lisman, FLGOFF Jarrad wrote:
>Just a quick question. This is my first attempt at using perl for scripting.
>All was going good until I wanted to do a secure copy (scp) from one box to
>another. Figuring I would just use the system() command I made a variable
>called $SCP_CMD which referred to the location of the scp install using the
>which command ie. $SCP_CMD = `which scp`. This little bit of code I pinched
>out of a shadow script where it worked fine. When using it in my own script
>system("$SCP_CMD .........");
>I kept getting an error as if I was using the wrong syntax for scp (ie. was
>getting the scp usage garbage put on my screen).
>After the mandatory several hours pulling my hair out and comparing my line
>of code with the one from Shadow, I tried the code again using the scp
>command straight out without first having it as a variable and it worked
>pefectly. Here are the two ldifferent lines... working and non-working, can
>someone explain to me what was causing me grief. (I would like to keep the
>script with the which command as it allows for use on other machines where
>the install dirs are not always the same as on my machine)
>system("scp -rq $srcfile $TARGET:$destfile");
>SCP_CMD = `which scp`;
>system("SCP_CMD -rq $srcfile $TARGET:$destfile");

Did this have a '$' sign or not?

Did it look like this:
system("SCP_CMD -rq $srcfile $TARGET:$destfile");
or this:
system("$SCP_CMD -rq $srcfile $TARGET:$destfile");

Also try this command print "($SCP_CMD)\n";

btw the whole point of using a variable is negated by using:
$SCP_CMD = `which scp`;
it would be as insecure to just use "scp".

If you are going to use a variable use the full path:
or whatever.

>error =
>usage: scp [Blah Blah Blah]
>Cheers for any info

Kim Holburn  Network Consultant  Ph: +61 2 61258620 M: +61 0417820641
Email: kim.holburn at - PGP Public Key on request

Life is complex - It has real and imaginary parts.
     Andrea Leistra (rec.arts.sf.written.Robert-jordan)

More information about the linux mailing list