[j-nsp] Running shell commands from ssh.

Vladimir S. Blazhkun v.blazhkun at pcs-net.net
Fri Mar 17 06:46:50 EST 2006


> Hi y'all,
>
> I seem to remember having seen a way to do this, but cannot find it
> anymore (checked the list, Juniper-clue, etc) -- I need to run some
> shell commands from a non-interactive ssh.
>
> I have tried various permutations of ssh <router> "start shell; ls;
> exit; exit" and similar things, but no luck. It seem that the
> commands that are passed in do not get handed to the shell....
>
> And no, I don;t want to create another user (or change an existing
> user) to have a shell of something other than "/usr/sbin/cli"
>
> Warren.

Write a simple script using expect/tcl/tk for this.

#!/usr/bin/expect --
set ssh "/usr/bin/ssh"
set timeout 30
spawn $ssh <router>
sleep 5
send "start shell\n"

and so on...

-- 
Vladimir S. Blazhkun,               Personal Communications Systems, LLC.
Leading IP NCC Specialist,          Work phone: +7 495 7847617 ext. 1101.
            JNCIA-J  JNCIA-M #773  JNCIS-M #1100  JNCIP-M #289


More information about the juniper-nsp mailing list