LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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-29-2009, 05:21 AM   #1
PMP
Member
 
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Rep: Reputation: 58
rc3 runlevel 3


I have a script that has following lines

echo "Here you are press any key to print next line"
read var
echo "This is the next line"


I have kept this script in /etc/rc3.d/

Now when system goes to runlevel 3 it executes the prompt but it does not wait for return key. It immediatly prints the next line. I want it to hold on till I press enter.

Is there any way to do it.
 
Old 07-29-2009, 07:54 AM   #2
PMP
Member
 
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Original Poster
Rep: Reputation: 58
Any clues
 
Old 07-29-2009, 07:59 AM   #3
timvandijk039
Member
 
Registered: Jul 2009
Location: The Netherlands
Distribution: Debian/Ubuntu and RHEL/CentOS
Posts: 42

Rep: Reputation: 18
Tested your situation and this work for me.

Hi PMP,

Tested your problem under Debian and the following worked for me.

Make test.sh script in /etc/init.d with the following shell code
Code:
#!/bin/sh
case "$1" in
	start)
		echo "Interactive test at startup"
		read var
		echo ${var}
		;;

	stop)
		echo "Interactive test at shutdown"
		read var
		echo ${var}
		;;

esac
After that create a link in the appropriate /etc/rc*.d (debians default runlevel is 2, Fedora's runlevel usually is 3 or 5)

Code:
ln -s /etc/init.d/test.sh S90test.sh
Of course you can do the same for the shutdown sequence, for example:
Code:
ln -s /etc/init.d/test.sh K10test.sh
That's it. Works like a charm.

Hope this helps.

Last edited by timvandijk039; 07-29-2009 at 08:04 AM.
 
Old 07-29-2009, 09:46 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by PMP View Post
Now when system goes to runlevel 3 it executes the prompt but it does not wait for return key. It immediatly prints the next line.
Interesting! timvandijk039 gave the pukka way of setting up a boot script but your script should work the way you set it up. The "read" should not return until it has read a line of input from stdin. Probably it did so. Might be interesting to print var in the message: echo "This is the next line. var is '$var'". The single quotes will help in case var contains only whitespace characters. Probably it is an empty line and the terminating line-end will have been stripped off so it will be empty. You could set var to something before the "read"; then, if var is empty after the "read" you would know the "read" had read an empty line.

Which distro are you using? Maybe some distros feed stuff to init scripts on stdin in case they are "badly" coded and try to read stdin which would hang boot -- which, I guess, is exactly what you are trying to do!

You may be able to find out where stdin is coming from by
Code:
ls -l /proc/$$/fd/0
What are you trying to achieve? If you want to pause boot then a symlink to /sbin/sulogin works nicely (ignore the error message about "start").

Best

Charles

Last edited by catkin; 07-29-2009 at 09:48 AM. Reason: Loads of typos!
 
Old 07-29-2009, 02:00 PM   #5
PMP
Member
 
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Original Poster
Rep: Reputation: 58
I am using solaris. I want to reboot it just after the my script finishes. but want user to know that the system is going to reboot. want a halt. but thats not happening.
 
Old 07-29-2009, 02:04 PM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by PMP View Post
I am using solaris. I want to reboot it just after the my script finishes. but want user to know that the system is going to reboot. want a halt. but thats not happening.
Good to know. Maybe we can progress that if you try some of my suggestions.
 
  


Reply

Tags
rc, runlevel



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
What's the difference between runlevel 2 and runlevel 5 in Debian? davidas Linux - Newbie 2 01-05-2012 01:10 PM
Problems starting runlevel 3 , redhat 7.3, "no more processes left in this runlevel" kiyoshi Linux - Software 1 06-25-2009 05:11 AM
New Install of PCLinuxOS boots into runlevel 3. Should be runlevel 5 MonctonJohn Linux - General 4 02-01-2008 04:38 PM
Go into runlevel 3 after a runlevel 4 crash davidguygc Linux - General 1 08-24-2007 08:23 PM
Soun Mixer absent in Runlevel 3 but present in Runlevel 5 debloxie SUSE / openSUSE 1 01-18-2006 09:15 AM

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

All times are GMT -5. The time now is 10:40 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