[SOLVED] How to wait at login prompt till the user press enter
Linux - NewbieThis 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!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
How to wait at login prompt till the user press enter
I am using run level 3 and added my own script in runlevel 3.
The script contains the line as the last line. runmyscript.sh 2>&1 | tee /home/bootlog.txt &
During reboot, the above process will run as a separate process and will give a banner at the end that running the script is successful.
But the problem is, I am not getting the banner. As soon the script starts to run, getting the login prompt as below.
My requirement is, when the process starts running, it should display the output of the script till the user press enter.
When the user press enter, the script should run in background and give login prompt.
pls help me in this.
I tried different ways, like tail the bootlog, and sleep command.
Please post your script or a representative example of the script because what you describe isn't too intuitive. If you're running a script from the init.d as part of system initialization, then likely stdout is not being directed to a particular user's terminal. If you wish to run a script everytime any user logs in, or certain users, then you can modify the global profile or the specific profiles per user and then cause the script to run.
At the very least post the specific actions you've taken, like: Modified <filename> a sample echo of "This is running" would be sufficient. Right now it's unclear what you've tried.
It sounds more like you want the script to be running BEFORE login.
Part of the problem is that getty/agetty initializes the terminal and provides the "login" prompt.
Now you can get around this by forcing the system to run something instead of getty/agetty - but that something will have to initialize the terminal, do the output, wait for the response... and then exec the login.
It also might be better to tell us what problem/requirement you are trying to solve.
Still not clear on what you're trying to do. I would not invoke with "2>&1 | tee".
I'd break this down into "debug output" and "intentional announcements".
As far as debug output. I wrote a blog about debugging bash scripts and covered my take on that here, and that entry covers much more scope beyond just output redirection.
What I prefer to do within the script is to use echo and ">" or ">>" redirectors to create and append to a log file. I also write the script where I check the return values from system commands, by checking the return variable $?. I've found that seeing stdout and stderr in cases of system call failures is way less useful to me than actually checking the result. What ends up going into my log file is debug of my own design where I report on what worked, what didn't, and the progress of my script; until I refine it to be what I want/need. I've also found that even if I do see stdout/stderr that it usually doesn't fully help me. Great, I know I have an error, but what I more need to know is what I gave to the system command. Because the "garbage in-garbage out" rule is usually true. It's great to know that a system command failed and what it's complaint is, but usually the problem is that what I gave it wasn't exactly what I "thought" I gave it. And I can't tell that by looking at stdout/stderr, but instead at an echo I made myself stating, "Calling .... with arguments ... and ..." Just my $0.02 there.
Sorry but I don't have much on the "intentional announcements" side of things. I know you can send a message to a terminal or a user, like the system can send an announcement like "System is rebooting", or "Hey Joe" to all terminals. I long ago played with that, a'la joking at peers by causing announcements to go to their terminals. First time that ends up going to the wrong person ... well that stops the workplace fooling around.
Your observation depends on how the terminal is setup.
In the bare machine it is done external to the software as the physical devices exist.
In the virtual machine, they get simulated. Now whether they get created on demand depends on the support for the VM. It is even possible they don't get initialized (as in the device doesn't work until after getty/agetty sets the parameters). This could explain why the output doesn't get displayed. Since the logs are a separate output from the tee as stdout, it is even possible that stdout is effectively /dev/null.