LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-26-2010, 10:52 AM   #1
moicpit
LQ Newbie
 
Registered: Mar 2010
Posts: 26

Rep: Reputation: 15
Question Running a script on front-ground on startup ?


Hi !

I would like to know how to run a BASH script on front-ground on startup of my machine.

I've installed a Damn Small Linux (DSL) on a old computer and I would like to run a script at stratup, in command-line mode. So, I've added my script in /etc/rc3.d and it's working fine except 1 thing : I would like it does not execute on background.

In facts, I would like the script take the hand immediatelly after login (my DSL is automatically login in with the DSLuser user).
The aim is that the script take the controle of the computer until it quit (the script is launching an application, wait for its stop and shutting down the PC).

Thanks !

Pit
 
Old 03-27-2010, 02:09 PM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
i think putting the script in ~/.profile or ~/.bash_profile would invoke it after login and as long as you dont put a & at the end, it wont background.
 
Old 03-27-2010, 11:51 PM   #3
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 moicpit View Post
I would like to know how to run a BASH script on front-ground on startup of my machine.

I've installed a Damn Small Linux (DSL) on a old computer and I would like to run a script at stratup, in command-line mode. So, I've added my script in /etc/rc3.d and it's working fine except 1 thing : I would like it does not execute on background.
"Foreground" means running in an interactive terminal. Boot scripts, run from the likes of the /etc/rc3.d directory are not running in an interactive terminal; they are sending their output to the console.

I think it is possible for a boot script to start a login shell running in a virtual terminal (including the one showing console output) and running a program but I do not know the details. It would probably need bash's --login and --rcfile options.

Quote:
Originally Posted by moicpit View Post
In facts, I would like the script take the hand immediatelly after login (my DSL is automatically login in with the DSLuser user).
Do you mean you want the script to run in the logged-in session? Or simply that it should run after the automatic login?

Quote:
Originally Posted by moicpit View Post
The aim is that the script take the controle of the computer until it quit (the script is launching an application, wait for its stop and shutting down the PC).
That is possible and does not need to be done in the foreground unless you want to interact with it.

It might be better if you tell us what you want to do rather than ask us how to implement your solution. We may be able to suggest a better solution.
 
Old 03-29-2010, 12:09 PM   #4
moicpit
LQ Newbie
 
Registered: Mar 2010
Posts: 26

Original Poster
Rep: Reputation: 15
Hi !

Thank you for your answers !

@ schneidz : Thank you very much ! Calling my script in ~/.bash_profile was the solution ! ;-)


Quote:
Originally Posted by catkin View Post
"Foreground" means running in an interactive terminal. Boot scripts, run from the likes of the /etc/rc3.d directory are not running in an interactive terminal; they are sending their output to the console.
OK, so I wanted to call it in "foreground", so I will move it out from /etc/rc3.d/.

Quote:
Originally Posted by catkin View Post
Do you mean you want the script to run in the logged-in session? Or simply that it should run after the automatic login?

That is possible and does not need to be done in the foreground unless you want to interact with it.
I mean that I want it to run in the logged-in session. And I have to interact with my script.

Quote:
Originally Posted by catkin View Post
It might be better if you tell us what you want to do rather than ask us how to implement your solution. We may be able to suggest a better solution.
The aim of my script is to launch an application that will capture the input (here, a keyboard) and make some actions regarding what key is pushed.
When we want to stop the computer, we kill the app (CTRL+C) and then the script will automatically shutdown the computer.

Here is an exemple of the script I want to use :
Code:
[Here some code to wait 5 seconds so that the user can cancel the script continuation and take the hand on the computer]
[calling of my app]
sudo shutdown now
 
  


Reply



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
Running Script on Startup jCash Linux - Newbie 3 05-20-2007 08:45 PM
Running a bash script at startup linker3000 Linux - Software 2 05-17-2007 10:00 PM
running .pl script on startup knowram Other *NIX 2 03-09-2007 09:50 PM
Running Perl Script upon startup andy7t Linux - Software 1 04-20-2005 04:43 PM
Running a script at systsem startup logo Linux - Newbie 1 09-21-2004 02:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:14 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
Open Source Consulting | Domain Registration