LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 04-06-2011, 07:36 AM   #1
ziggycat
LQ Newbie
 
Registered: Apr 2011
Posts: 3

Rep: Reputation: 0
how can I resume a bash script after a reboot in a terminal window?


this has been driving me crazy all week, no matter what I try it just wont work.

I have written a script that installs several programs, half way through it requires the machine to be rebooted.

what I've been trying do do without success, is when the system restarts a terminal window opens and the script resumes.

I've googled this, and it seems other people have aslo tried and failed to acheive the desired result.

ok, I know it would be easy to just run the script without the terminal window (using cron @reboot or rc.local), but I really need the verbose output as the user must make 2 selections on the remaing installations.

So if anyone knows how to open a terminal and run a script after startup, could they please please let me know how to do it.

many thanks.

Last edited by ziggycat; 04-06-2011 at 07:37 AM.
 
Old 04-06-2011, 01:11 PM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,297

Rep: Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322
In your script, at the start:
if $CONTINUE=1 then go to half way point #the post reboot stage.
fi
. . . (later)
touch /tmp/some_file && reboot # You reboot here

in your startup:

if ( -f /tmp/some_file; ) then
CONTINUE=1 /path/to/script
fi

let the half way point bit zap the tmpfile, add/correct all the syntax and try it. If you need the state of half a dozen variables, just echo them to(>>) the tmpfile, and read them back in.
 
Old 04-07-2011, 02:00 AM   #3
ziggycat
LQ Newbie
 
Registered: Apr 2011
Posts: 3

Original Poster
Rep: Reputation: 0
cheers for the reply mate,

its easy enough to get the script to restart from where I need it to, just getting a terminal window open with the script running after a rebbot is the impossible bit.

any ideas?
 
Old 04-07-2011, 03:30 AM   #4
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,297

Rep: Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322
I would run from init, & output to a file unless you require interaction. You can run tail or less on the file. But if you r4equire interaction, you can restart the thing.
 
  


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
[SOLVED] How to make a bash script keep running in same terminal after it calls second script? JohnRock Linux - Newbie 4 06-25-2010 09:16 AM
copying text from terminal BASH window to a webpage. mdlinuxwolf Linux - Newbie 4 10-30-2009 07:13 PM
Bash script to launch a terminal window on another user's desktop Excalibre Linux - Software 7 09-29-2008 02:01 AM
Trying to launch a new term window while executing a bash script in that window sfmadmax Linux - Newbie 5 12-09-2007 01:34 PM
How can a bash script findout the width of the terminal window alex.e.c Linux - Software 2 10-14-2004 11:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

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