LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-20-2015, 01:11 PM   #1
neo3matrix
LQ Newbie
 
Registered: Nov 2009
Posts: 12

Rep: Reputation: 0
Replace login prompt with interactive bash script on serial port


Hi Guys,



I am working on a CentOS box.

What I expect: To run my own CLI/setup on startup instead of login prompt on serial console (telnet).

What I did so far:- I changed call to "agetty" command in serial.conf and serial-ttyUSB0.conf files under /etc/init/, as follows:-

exec /sbin/agetty -n -l <path-to-my-custom-script> ........

My custom.sh script is:-

#!/bin/bash

LOOP_FLAG=0
while [ $LOOP_FLAG -eq 0 ]; do
for TTY in /dev/ttyS0 /dev/tty0; do
echo "Please choose to enter in 'setup' or 'cli'. (s/c)? " > $TTY
done
read sc
case $sc in
[Ss]* ) LOOP_FLAG=1; <some-executable-cli-file-path>; break;;
[Cc]* ) LOOP_FLAG=1; <some-executable-setup-file-path>; break;;
* ) for TTY in /dev/ttyS0 /dev/tty0; do
echo "Please press 's' or 'c'." >$TTY
done;;
esac
done

But when system boots, on a telnet session, I could only see the "Please choose to enter.." question on screen and after that I couldn't able to type anything on console.

One more update: If I run the above agetty command on shell prompt as it is (say from ssh session), then it works fine on serial console (telnet). But, from the above startup scripts, it doesn't work.

Can anybody help me out with this?

Thanks in advance.

-Neo
 
Old 01-21-2015, 12:07 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,137

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
When you are typing to a shell or to login it echos what you type so that you see it. Your script isn't doing that.
 
  


Reply

Tags
bash, console, linux, login, upstart


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script to recieve and send data for serial port ffonseca Linux - Software 6 12-15-2014 01:09 PM
[SOLVED] Bash Serial port Script wont hang up mmof Linux - Newbie 3 10-26-2010 01:16 PM
Creating a bash script with serial port input Elv13 Linux - Hardware 10 06-08-2010 07:01 AM
Why can't I read in data from the serial port using a bash script? tjt Linux - Newbie 1 06-17-2004 12:21 AM
make bash interactive and change prompt DropSig Linux - Newbie 3 05-17-2004 08:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration