[EMAIL PROTECTED] wrote:
I am using perl alarm within a script and having an issue. I want to
access a host by first trying rsh and if that fails use ssh. I can
get the command to run with only one of the commands but when I add
both it fails. I must be missing something simple
Here is the info:
Part of script
.... else { $cmd="perl -e 'alarm(5);exec
qq/${rdist} -cR \$srcdir $ENV{host}:\$destdir ||${scp} -pr \$srcdir
$ENV{host}:\$destdir/'"; }
Error I get
Bareword found where operator expected at -e line 1, near "qq//usr"
syntax error at -e line 1, near "qq//usr"
Bareword found where operator expected at -e line 1, near "/bin/scp"
(Missing operator before p?)
Execution of -e aborted due to compilation errors.
I have already set the rdist variable and have even tried to specify
the rdist path.
How simply awful. Lets reformat this so it's a little more legible:
else {
$cmd = "
perl -e '
alarm(5);
exec qq/
${rdist} -cR \$srcdir $ENV{host}:
\$destdir || ${scp} -pr \$srcdir $ENV{host}:
\$destdir
/
'
"
}
now from your error messages I would guess that
$rdist = '/usr/bin/rdist'
and
$scp = '/usr/bin/scp'
or something like that, so your Perl now becomes:
else {
$cmd = "
perl -e '
alarm(5);
exec qq/
/usr/bin/rdist -cR \$srcdir $ENV{host}:
\$destdir || /usr/bin/scp -pr \$srcdir $ENV{host}:
\$destdir
/
'
"
}
Can you see now why you're getting a syntax error?
But your concept is far too convoluted. You have a Perl process that's
shelling out to another Perl process, that in turn is shelling out to
run rsh and/or ssh. Also, where are $srcdir and $destdir coming from?
I suggest you rewrite as a Perl program that shells out, if necessary
only one level to rsh, and verifies the return status to determine
whether to also use ssh in the same way.
I hope this helps a little.
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/