LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Kermit Scripting syntax (https://www.linuxquestions.org/questions/linux-newbie-8/kermit-scripting-syntax-4175533972/)

AID50NY 02-13-2015 11:47 PM

Kermit Scripting syntax
 
Hello folks
I have a little Raspberry Pi box running Debian that I use
as a Terminal server for connecting to my Routers and switches.
7 devices in total so I am trying to create a script
from the stand-alone commands I type to connect.
kermit -l /dev/ttyUSB0
set carrier-watch off
connect.
Individually these lines work.

In a script
#!/bin/sh
kermit -l /dev/ttyUSB0
set carrier-watch off
connect

or

#!/bin/sh
kermit -l /dev/ttyUSB0 "set carrier-watch off, connect"
or
anything else does not work.

What am I missing?

Thanks

codeguy 02-15-2015 08:35 PM

I've never used kermit, so this is a guess. I'll bet kermit is starting a console that you then enter the commands "set ..." and "connect" into.

But when you run it as a bash script, the kermit command starts and bash will wait for it to finish before running the next line of the script. (Bash doesn't know to send the two lines to kermit. Its going to try to run them as if they were bash commands).

Try something like:

#!/bin/sh
echo <<EOF | kermit -l /dev/ttyUSB0
set carrier-watch off
connect
EOF


That'll run kermit, and then pipe everything until EOF to it. <<EOF is called a heredoc and the pipe is called a pipe. (Its the thing by the backslash).


All times are GMT -5. The time now is 02:55 PM.