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 - 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-04-2008, 03:26 PM   #1
jaredhanks
LQ Newbie
 
Registered: May 2006
Posts: 23

Rep: Reputation: 15
Best way to run a script???


Hello,

I'm writing a shell script and was wondering what the best way to have the script execute another script would be. The basics are:

Script1 would ask user for a 3 digit number. Let's say variable=250.
Script1 would then ask if 250 is really the number inputted, else it would exit.
Script1 would then kick off Script2, and exit to command line while Script2 continues to run in the background.

I know I can run nohup ./Script2 & and the output would go to nohup.out, but I want it to output to a different file (something like Log_$variable.out).

Is there a better way to do this? Can I have define where nohup sends output, instead of nohup.out?

Any help is appreciated.

Thanks,
Jared
 
Old 03-04-2008, 04:08 PM   #2
budword
Member
 
Registered: Apr 2003
Location: Wisconsin
Distribution: Switched to regualr Ubuntu, because I don't like KDE4, at all. Looks like vista on crack.....
Posts: 675

Rep: Reputation: 31
I'm not a scripting expert, but have you thought about using perl to do this ? Then you can specify the output file exactly. Bash I don't know enough about to offer useful advice.

Good luck though...

David
 
Old 03-04-2008, 06:01 PM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
You can run Script2 just like any other executable. Redirect any of its input/output streams, and run it in the foreground or background as appropriate. Since you know that it is, in fact, a script you can also 'source' it.
--- rod.
 
  


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
Is a script, run at boot time from init.d, run with root authority? tmbrwolf53 Linux - Server 2 03-31-2007 08:15 PM
how to run a shell script in the perl script sharad Linux - General 1 05-24-2006 03:23 AM
'cannot stat' script in /etc/rc.d/, try to run script at startup quintan Linux - Software 1 11-21-2005 02:53 AM
on Network Up Script run? On Battery power run script? v2-ncl Linux - General 0 12-08-2003 09:34 AM
can't run a script script from icon in konqueror scottsteibel Linux - Software 1 08-02-2003 07:59 PM

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

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