Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


  Search this Thread
Old 01-20-2015, 02:11 PM   #1
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 script is:-


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
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

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.

Old 01-21-2015, 01:07 PM   #2
Senior Member
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 & 7
Posts: 3,046

Rep: Reputation: 813Reputation: 813Reputation: 813Reputation: 813Reputation: 813Reputation: 813Reputation: 813
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.


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 02:09 PM
[SOLVED] Bash Serial port Script wont hang up mmof Linux - Newbie 3 10-26-2010 02:16 PM
Creating a bash script with serial port input Elv13 Linux - Hardware 10 06-08-2010 08:01 AM
Why can't I read in data from the serial port using a bash script? tjt Linux - Newbie 1 06-17-2004 01:21 AM
make bash interactive and change prompt DropSig Linux - Newbie 3 05-17-2004 09:16 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:15 PM.

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