LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-03-2014, 05:30 AM   #1
BhushanPathak
Member
 
Registered: Nov 2013
Location: Pune, India
Distribution: CentOS
Posts: 53

Rep: Reputation: Disabled
Linux read command not displaying entered data on console during OS boot


Hello,

I have CentOS 6.5 x86_64 running as a VM on VMware[ESXi Host].

I have a simple script which asks for user inputs using read command & then stores them in a text file. For ex -

Code:
echo -e "Please enter IP"
read IP

echo "IP is - $IP" >> /tmp/input.txt
This script is executed as the 36th boot process [by creating a soft link /etc/rc.d/rc3.d/S36_bootprocessscript -> the actual script].

The issue I am facing is that when I manually execute the script as root user in an SSH session, the user input I type is displayed on the console. But during the boot process, it does not. The script properly accepts the user input & writes to the text file, but does not display it on console.

Is there anything wrong I am doing?

Kernel version - 2.6.32-431.17.1.el6.x86_64

Thanks
Bhushan Pathak
 
Old 07-03-2014, 05:54 AM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,702

Rep: Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270
You are assuming stdin and stdout is attached to the process. It isn't.

You can try to "echo ... >/dev/tty", but I'm not certain that a controlling terminal is assigned either.

Part of the problem is that the terminal devices have not necessarily been initialized.

BTW, things change in the new RHEL and the use of systemd causes a LOT of things to change.

What MIGHT work is "echo ... >/dev/tty1" and perhaps "read IP </dev/tty1"

It may not work the way you want as /dev/tty1 is not necessarily configured for use (it isn't logged in, thus no environment variables nor modes are set the way you might expect).

Last edited by jpollard; 07-03-2014 at 06:01 AM.
 
Old 07-07-2014, 04:08 AM   #3
BhushanPathak
Member
 
Registered: Nov 2013
Location: Pune, India
Distribution: CentOS
Posts: 53

Original Poster
Rep: Reputation: Disabled
I will try that out.

- Bhushan
 
Old 08-18-2014, 06:07 AM   #4
BhushanPathak
Member
 
Registered: Nov 2013
Location: Pune, India
Distribution: CentOS
Posts: 53

Original Poster
Rep: Reputation: Disabled
I tried the /dev/tty1 option. All the echo messages I redirected to /dev/tty1 were not displayed on console. All inputs I entered were accepted but did not show on console either [my original problem].

- Bhushan
 
Old 08-18-2014, 06:18 AM   #5
BhushanPathak
Member
 
Registered: Nov 2013
Location: Pune, India
Distribution: CentOS
Posts: 53

Original Poster
Rep: Reputation: Disabled
I even changed the script to run last as part of the boot process [S99], still the same issue exists.

- Bhushan
 
Old 08-18-2014, 05:41 PM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,702

Rep: Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270
That makes it odd. Are the boot messages being displayed?
 
Old 08-19-2014, 09:12 AM   #7
BhushanPathak
Member
 
Registered: Nov 2013
Location: Pune, India
Distribution: CentOS
Posts: 53

Original Poster
Rep: Reputation: Disabled
Yes, the boot messages are displayed. The echo messages I have added in the script are also displayed.
Note that when I changed the script to run as last process [S99], it did not have the /dev/tty1 changes in it.
 
Old 09-17-2014, 05:18 AM   #8
BhushanPathak
Member
 
Registered: Nov 2013
Location: Pune, India
Distribution: CentOS
Posts: 53

Original Poster
Rep: Reputation: Disabled
Adding the following at the start of the script did the trick script -

Code:
plymouth quit
echo -e "Please enter IP"
read IP

echo "IP is - $IP" >> /tmp/input.txt
 
  


Reply


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Read pcap data in console bgs@pt Linux - Networking 6 10-16-2013 05:04 PM
Repeat last entered command ? Vilius AIX 17 08-12-2011 06:54 AM
[SOLVED] HTML Form that sends data entered to a bash script as variables simplified Programming 2 12-01-2009 03:35 PM
is there any shell command to read and write data from parallel and serial port? baosheng Linux - Hardware 2 01-13-2007 08:35 PM
Burn Data DVD... Read Data in Linux and Windows SaintStrive Linux - Newbie 3 09-18-2004 05:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:55 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration