first attempt at perl (SEC: UNCLASSIFIED)
Richard Cottrill
richard_c at tpg.com.au
Fri Apr 19 18:02:35 EST 2002
If you're getting the usage whinge from scp then it's not a problem with
your SCP_CMD variable.
It's been a long time since I hacked Perl, but here's my interpretation of
what you should be doing:
// always include these two lines (or whatever your system requires!!!
#!/usr/bin/perl -w
use strict;
//or whatever - always!!!
$SCP_CMD = `which scp`;
print "$SCP_CMD -rq $srcfile $TARGET:$destfile/n"; //for God's sake get
` //some debugging info
system("$SCP_CMD -rq $srcfile $TARGET:$destfile");
I think your problem lies in the 'everything else' section.
Richard
> -----Original Message-----
> From: linux-admin at lists.samba.org [mailto:linux-admin at lists.samba.org]On
> Behalf Of Lisman, FLGOFF Jarrad
> Sent: Friday, April 19, 2002 4:45 AM
> To: 'linux at lists.samba.org'
> Subject: first attempt at perl (SEC: UNCLASSIFIED)
>
>
> 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