first attempt at perl (SEC: UNCLASSIFIED)

Lisman, FLGOFF Jarrad Jarrad.Lisman at defence.gov.au
Fri Apr 19 13:45:14 EST 2002


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)

WORKING
system("scp -rq $srcfile $TARGET:$destfile");

Non WORKING
SCP_CMD = `which scp`;
system("SCP_CMD -rq $srcfile $TARGET:$destfile");

error = 

usage: scp [Blah Blah Blah]

Cheers for any info

Jarrad





More information about the linux mailing list