ssh in system call

K

Klaus Boon

Hi,

I used a shell script to automaticly start another
shell script in the background of some remote
hosts (everything is configured so that no password
is needed)
ssh $host tasks.sh &

now I ported everything to perl
system("ssh $host tasks.sh &");

and get problems. While running this line perl does
start my tasks.sh but also does a real login on the
specified $host's (what i dont want). Thus I have to
exit all the connections by hand. I also tried using
the ssh-params -f and -N together with or without
the & the results get even more weird.

Can anybody tell me how to write this system call
correctly?

TIA Klaus
 
E

Eric J. Roode

Can anybody tell me how to write this system call
correctly?

It sounds like your problem has nothing to do with Perl.

Perhaps you could try in a unix or security newsgroup, where more people
are more likely to have useful information about ssh.

HTH,
--
Eric
`$=`;$_=\%!;($_)=/(.)/;$==++$|;($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:,@%)=(
$!=~/(.)(.).(.)(.)(.)(.)..(.)(.)(.)..(.)......(.)/,$"),$=++;$.++;$.++;
$_++;$_++;($_,$\,$,)=($~.$"."$;$/$%[$?]$_$\$,$:$%[$?]",$"&$~,$#,);$,++
;$,++;$^|=$";`$_$\$,$/$:$;$~$*$%[$?]$.$~$*${#}$%[$?]$;$\$"$^$~$*.>&$=`
 
P

Paul Lalli

Klaus said:
I used a shell script to automaticly start another
shell script in the background of some remote
hosts (everything is configured so that no password
is needed)

If this "works"...
now I ported everything to perl

.... there's no way this will work at all...
and get problems. While running this line perl does
start my tasks.sh but also does a real login on the
specified $host's (what i dont want).

..... but not in the way you describe.

Perl will interpolate $host in that double quoted string as it's own
variable, not as the shell variable.

Therefore, you are not giving us the actual lines of code you are
using. Therefore, reading the remainder of your post is pointless.

Please read the posting guidelines for this group. Then follow their
advice: Post a short-but-complete script which we can copy and paste
which demonstrates your error. Post explicitly the exact output you
receive, and the exact output you expect to receive.

Paul Lalli
 
U

usenet

Klaus said:
now I ported everything to perl

That's not porting anything to Perl. That's using Perl like ksh or
bash. There is rarely a good reason to ever use a 'system' command in
Perl. Perl is much more than a framework to string together OS shell
commands.
Can anybody tell me how to write this system call correctly?

Yes, REALLY port your application to Perl by using a genuine Perl
module:
http://search.cpan.org/~ivan/Net-SSH-0.08/SSH.pm
 
U

usenet

Klaus said:
now I ported everything to perl

That's not "porting" anything to Perl. That's using Perl like ksh or
bash. There is rarely a good reason to ever use a 'system' command in
Perl. Perl is much more than a framework to string together OS shell
commands.
Can anybody tell me how to write this system call correctly?

Yes, REALLY port your application to Perl by using a genuine Perl
module:
http://search.cpan.org/~ivan/Net-SSH-0.08/SSH.pm
 
U

usenet

Klaus said:
now I ported everything to perl

That's not "porting" anything to Perl. That's using Perl like ksh or
bash. There is rarely a good reason to ever use a 'system' command in
Perl. Perl is much more than a framework to string together OS shell
commands.
Can anybody tell me how to write this system call correctly?

Yes, REALLY port your application to Perl by using a genuine Perl
module:
http://search.cpan.org/~ivan/Net-SSH-0.08/SSH.pm
 
J

Joe Smith

Klaus said:
I have to exit all the connections by hand.

It's the same as when running ssh manually.

host1% ssh host2
host2% tasks.sh &
host2% exit
[connection hangs until you type "~" and "Control-Z"]
host1% kill %1

It's caused by the background process on host2 having
the SSH connection's STDIN, STDOUT, and/or STDERR open.

system("ssh $host tasks.sh </dev/null >>logfile 2>&1 &");
or
system("ssh $host tasks.sh </dev/null >>/dev/null 2>&1 &");

Or use a perl SSH module that gives you more control over
the SSH connection.
-Joe
 
G

Gary E. Ansok

and get problems. While running this line perl does
start my tasks.sh but also does a real login on the
specified $host's (what i dont want).

You don't show us how $host is set -- are you sure it contains
exactly what you think it does?

A line like print "Host = >>$host<<\n" can be helpful in
verifying this.

You may also want to check out the Perl function chomp()
(perldoc -f chomp).

Gary
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top