Hey monks,
I'm still working on this ssh script. I can get my script to work, but when the firewall dameon is not running and I give the command to bring down the interface ($cmd2)on the other computer, perl just hangs there. Is there a way to break out of the ssh shell after bringing the interfaces down? Also, once I break out of the ssh shell, I want to run some commands on the local machine such as: ifconfig eth0 up and fwstart. How should I incorporate these commands into my script? I would rather not use Net::SSH or Net::SSH::Perl
Thanks for the help,#!/usr/bin/perl -w my $result; my $sshprog="/usr/bin/ssh"; my $sshhost="192.168.2.3"; my $sshuser="root"; my $cmd1="ps -ef | grep -v grep |grep fwd"; my $cmd2="ifconfig eth0 down"; $result=`$sshprog $sshuser\@$sshhost $cmd1 2>&1`; if ($? == 0) { print "Firewall Dameon is running\n"; exit 0 } # end if ($? != 0) if ($? != 0) { print "Firewall Dameon is not running. Bringing down the interfaces\ +n"; $result=`$sshprog $sshuser\@$sshhost\ $cmd2 2>&1`; exit 0 } # end if ($result != 0)
In reply to Can't Break Out of SSH Shell by dru145
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |