I wrote the following in a kermit
script to connect to my serial device:
#!/usr/bin/env kermit
set port /dev/ttyUSB8
set speed 115200
set carrier-watch off
set flow-control none
set prefixing all
set input echo on
It does the job pretty well. Now, I want to make this a generic script and would like to take the input from the user which port he wants to connect. So, I thought taking input as a commandline argument is the best way to do. And I modified the above in the following way:
#!/usr/bin/env kermit
port_num="/dev/ttyUSB"+$1
set port port_num
set speed 115200
set carrier-watch off
set flow-control none
set prefixing all
set input echo on
But, I get the following error:
user4@user-pc-4:~/Scripts$ ./test.script 8
?Not a command or macro name: "port_num="/dev/ttyUSB$1""
File: /home/Scripts/test.script, Line: 2
port_num
?SET SPEED has no effect without prior SET LINE
"8" - invalid command-line option, type "kermit -h" for help
I tried replacing
port_num="/dev/ttyUSB"+$1
with
port_num="/dev/ttyUSB$1"
as well.
There is an obvious flaw in my second script. How can I get the script to accept the user input and connect to the serial port using kermit
?