I have a Brocade FC switch that I'd like to do some zoning on. I have a build file with too many lines to copy-paste into a normal interactive session, and I have ssh set up with pre-shared keys between the switch and my unix management server. I do not have expect and would prefer to stick to straight ssh and bash.

I've tried sending the commands individually, however it fails because each ssh command is an individual session, and all uncommitted commands are flushed as soon as the session is dropped.

I've tried this:

cat testbuildfile | ssh -tt user@switch

It almost works, in that it runs all the commands in my build file, however it leaves me with a session on the Brocade I can't use when they're finished. I have my Brocade command prompt, but if I enter anything, it hangs and I have to ctrl-c to get back to my unix server.

I know that I can put the commit command into my build file, but I'd rather have a chance to check and validate the work before committing it. Ideally, I'd like to have it run my command file and then leave me logged into the session it started for me to check and then manually commit the commands. Can I do this?

edit: running scripts on the Brocade switches is not possible without an elevated shell that would void the warranty.


Right - you've hijacked stdin in the ssh session and it's no longer connected to your terminal. Unless you add quit into the command stream it'll hang.

Try this magic instead:

CR="$(echo -e '\r')"

screen -d -m -S $session
screen -S $session -p 0 -X zombie kr
screen -S $session -p 0 -X hardstatus alwayslastline
screen -S $session -p 0 -X hardstatus string "$host config change 3.14159"
screen -S $session -p 0 -X stuff "exec ssh -l USERID $host$CR"
sleep 2
screen -S $session -p 0 -X stuff "PASSW0RD$CR"
sleep 5
screen -S $session -p 0 -X stuff "version$CR"
sleep 2
screen -S $session -p 0 -X stuff "# Changes complete - commit or abort$CR"
screen -x $session
| improve this answer | |
  • I don't have screen installed on AIX... but reading about it, it certainly seems like something worth fighting to get. In the meantime, though, is there anything in the world of sessions, pipes, and redirection that can get me where I need to be? – Basil Jul 1 '14 at 12:14
  • @Basil Dude you have nothing :) I'd probably end up writing a program that spawned SSH, injected a bunch of its own commands then waited for input on stdin and passed it along to the process. Or fighting for screen. – MikeyB Jul 2 '14 at 14:07
  • Thanks :) I'm considering that program option, but it's a shame that Brocade makes this so hard. – Basil Jul 3 '14 at 16:09
  • I think you can configdownload a partial config as well. But that's why they want you to buy their tools :) – MikeyB Jul 3 '14 at 16:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.