Reputation: 1395
I am looking to send a 'reboot' command over the serial port to the PDU. What I have to do in the interactive mode is this:
#screen /dev/ttyS1
>reboot
>[Detach Screen]
#
If I want to automate this task in a script, I should be able to reboot the PDU with a single command from shell like this:
#echo "reboot" >/dev/ttyS1
However, it does not work ! I don't know why.... Would you be able to help me ?
The PDU manual request baud rate of 9600 which is not a default baud rate. I have tried following command to set the baud rate but still no lock:
stty -F /dev/ttyS1 speed 9600 cs8 -cstopb -parenb
These outputs does not change with or without screen:
# stty -a -F /dev/ttyS1
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^H; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 100; time = 2;
-parenb -parodd cs8 -hupcl -cstopb cread clocal -crtscts
-ignbrk brkint ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke
Upvotes: 4
Views: 16953
Reputation: 1395
Here is how we fixed this issue:
Config serial port with RAW setting:
stty -F /dev/ttyS1 speed 9600 cs8 -cstopb -parenb raw
Send Command using echo with \r:
echo -ne "reboot\r" > /dev/ttyS1
I believe that the above might include a typo. If the above doesn't work, try:
echo -ne "reboot\n\r" > /dev/ttyS1
Upvotes: 5