LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 07-27-2006, 12:29 AM   #1
Cheechi
Member
 
Registered: Jun 2004
Distribution: SuSE since 7.0, Ubuntu since 04
Posts: 75

Rep: Reputation: 15
scripting for dummies (me)


I run a number of Linux systems that are primarily torrent down/uploaders, print servers, or works in progress (the kind that sit for months). This said, the primary job of all these systems is to run Folding@Home because they're fun to mess with sometimes and learn stuff, but can be put to good use when i'm not in the mood. I would like to make a script, program, or whatever that does the following:

Open up a terminal (no real preference)
cd ~/fah/n (n being a number 1-4 on my multiple cpu boxes)
chmod +x ./FAH504-Linux.exe
./FAH504-Linux.exe
(for multiple processor machines, i have to run multiple instances, this is probably the most tricky part of it)
This program runs in a terminal, and is already installed and set up correctly. I'm tired of having to manually restart the process after an outage of net, power, etc. only to find out that it could have been folding the whole time but wasn't. I typically use these boxes through VNC but that probably will not make much difference. Ideally i'd like a solution that will work on any linux system, but in case it's important the machines run Suse 10 and Ubuntu 6.06

Thanks for the help!
 
Old 07-27-2006, 12:39 AM   #2
crazyjimbo
Member
 
Registered: Mar 2006
Location: Edinburgh
Distribution: Debian Etch, Gentoo
Posts: 90

Rep: Reputation: 16
Im no expert on scripting but as they are all commands you would run in a shell, the shell script to run them all automatically should just look like this:

Code:
#!/bin/sh

cd ~/fah/n 
chmod +x ./FAH504-Linux.exe
./FAH504-Linux.exe
Change its permissions to executable and you're away!

If you replace n by $1 then you can pass n as an argument to the script

Last edited by crazyjimbo; 07-27-2006 at 12:40 AM.
 
Old 07-27-2006, 04:55 PM   #3
Cheechi
Member
 
Registered: Jun 2004
Distribution: SuSE since 7.0, Ubuntu since 04
Posts: 75

Original Poster
Rep: Reputation: 15
would this give me a terminal window/tab with the program running, or would it essentially be a service. A terminal window would be best (tabs for multiple cores) as i could see any error without having to open the log (as it is in use whenever the program is running) to fix anything that would require it.

And in which file would i add these lines? or is it a new script? if
it's new where would i put it? what would i name it? I appreciate your help, just that i'm largely ignorant of these things and am eager to learn.
 
Old 07-27-2006, 07:38 PM   #4
crazyjimbo
Member
 
Registered: Mar 2006
Location: Edinburgh
Distribution: Debian Etch, Gentoo
Posts: 90

Rep: Reputation: 16
This wouldn't give you a terminal, it would just execute the commands. If you ran it FROM a terminal, then the results would appear within the terminal.

The script is run by a shell which is responsible for executing the commands you type/script. A terminal simply allows you to type things to the shell and displays the output of programs run by the shell. I hope that makes sense. I suggest reading man bash and the manual pages for your terminal for more information - or google!

So to run that program within a terminal, the script will have to open a terminal which is a program like any other and then instruct the terminal to run commands. I've probably lost you by now so here is an example script: (I use gnome-terminal and this is the terminal that will be run by this script. If you prefer a different one then I would consult the man page for the equivelent commands)

Code:
#!/bin/sh

#You don't need to see the output of these so they don't need run in a terminal
cd ~/fah/n
chmod +x ./FAH504-Linux.exe

#open gnome-terminal
gnome-terminal \   
--tab-with-profile=default -e ./FAH504-Linux.exe \
--tab-with-profile=default -e ./FAH504-Linux.exe \
--tab-with-profile=default -e ./FAH504-Linux.exe
#add as many of the previous line as you want tabs.
I would put this script into a file on its own. It can be run by executing the file from a terminal or on boot (how to do this depends on the distro you are using).

Last edited by crazyjimbo; 07-27-2006 at 07:40 PM.
 
Old 07-28-2006, 03:09 PM   #5
Cheechi
Member
 
Registered: Jun 2004
Distribution: SuSE since 7.0, Ubuntu since 04
Posts: 75

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by crazyjimbo
I would put this script into a file on its own. It can be run by executing the file from a terminal or on boot (how to do this depends on the distro you are using).
Thanks, i'm beginning to see the picture now a bit more clearly. i've created a fah.sh containing the essence of what you've got (you mostly just steered me in the right direction) I'm using Konsole and i think kdcop may be the reason i'm not getting mine to work.

In Suse, would it be best to put this data in .bashrc so whenever i log into my account it would start? I also have a few Ubuntu systems. I don't mind doing it manually but for the reason of wasting time i'd like it as automated as possible - meaning at logon.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 04:29 AM
SUSE Linux 9.3 for Dummies (For Dummies S.) samuelmp SUSE / openSUSE 11 08-01-2005 01:42 PM
C++ For Dummies AFI_Flame Programming 6 10-15-2004 02:00 PM
mandrake for dummies huffboy Linux - Newbie 2 04-27-2004 09:43 PM
eBooke for dummies deWin Linux - General 2 02-23-2004 03:22 PM

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

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