LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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!

Notices


Reply
  Search this Thread
Old 05-02-2006, 10:18 AM   #1
assasukasse
Member
 
Registered: Mar 2006
Location: UK
Distribution: Debian, Ubuntu
Posts: 132

Rep: Reputation: 15
making a script..


I am using a program that runs in this way (for university)
i call it from bask with this syntax: ./nameprogram inp=inpfile xsdir=xsdir2
it runs for around 5 hours then gives me 3 files
after that, i start again with another filename
runs for 5 hours again, then gives me 3 different files (the program looks for the filename and appends 1-2-3 to different files)
now since i can't be there every 5 hours to start again, i wish to make a script that would do for me:
i should start the script and it would care of all the files i list for example on a file by running the program with each one of them..
where can i find info about how to do that?
Thanks
 
Old 05-02-2006, 11:22 AM   #2
BinJajer
Member
 
Registered: Sep 2005
Location: Warsaw, Poland
Distribution: Slackware 10.2, Caldera OpenLinux 3.1, Corel Linux (Thanks xhi!), Debian GNU/HURD etc...
Posts: 296
Blog Entries: 1

Rep: Reputation: 30
Tried perl? Hmmm, haven't used it for some time now, but it should be somthing like this:

Code:
#!/usr/bin/perl
@files = <STDIN>;
chomp (@files);
foreach (@files) do {
exec /path/to/nameprogram inp= $_ xsdir=xsdir2
}
Hmm, I'm pretty sure that something is wrong in this script (probably a lot) but it should be a good backbone. Take some time, ask around perlmonks.com, look into the perl documentation. As I said, I haven't been using perl for a lot of time now...
 
Old 05-02-2006, 11:38 AM   #3
mbreith
Member
 
Registered: Feb 2006
Location: oregon
Distribution: PIII fedora2 | P4 fedora2 | Thinkpad fedora2
Posts: 54

Rep: Reputation: 15
You could set it up as a cron job instead of a script.
 
Old 05-02-2006, 11:46 AM   #4
BinJajer
Member
 
Registered: Sep 2005
Location: Warsaw, Poland
Distribution: Slackware 10.2, Caldera OpenLinux 3.1, Corel Linux (Thanks xhi!), Debian GNU/HURD etc...
Posts: 296
Blog Entries: 1

Rep: Reputation: 30
Thought about that too, but what assasukasse want to just put in some filenames, and let it execute itself. Sort of like a frontend. And why a Cron job? Can't we have some multiprocessing here? That's why I used "exec" instead of "system". Hello, we're in XXI century!
 
Old 05-02-2006, 05:34 PM   #5
Lotharster
Member
 
Registered: Nov 2005
Posts: 144

Rep: Reputation: 18
You can pass several commands to the bash by seperating them with semicolons.
E. g, you could enter:
Code:
./nameprogram inp=inpfile1 xsdir=xsdir2 ; ./nameprogram inp=inpfile2 xsdir=xsdir2 ; ./nameprogram inp=inpfile3 xsdir=xsdir2
which would execute the program three times in a row with different input files (1, 2 and 3). If you want someting more elaborate, try writing a bash script. There are some good tutorials out there, e. g. http://www.freeos.com/guides/lsst/index.html

good luck,

Lotharster
 
Old 05-03-2006, 03:06 AM   #6
assasukasse
Member
 
Registered: Mar 2006
Location: UK
Distribution: Debian, Ubuntu
Posts: 132

Original Poster
Rep: Reputation: 15
with some help on irc i finally wrote this:
#!/bin/sh
echo "---------------------------------------------"
echo " script by assasukasse, linux only please"
echo "---------------------------------------------"
mkdir ./done
for I in `ls *.w`
do
echo "start $I"
./xyz inp=$I xsdir=xsdir2
mv $I ./done
echo "done $I"
done

it works wonderfully..however i have a small problem..
i wish to give more visibility to the echoes..
how can i color them?
Thanks
 
Old 06-02-2006, 03:17 AM   #7
muha
Member
 
Registered: Nov 2005
Distribution: xubuntu, grml
Posts: 451

Rep: Reputation: 37
Google helps:
http://www.faqs.org/docs/abs/HTML/colorizing.html
Quote:
echo -e '\E[37;44m'"\033[1mContact List\033[0m"
 
  


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
Need help in making script depam Linux - Software 1 10-19-2005 07:40 PM
making a bash script student04 Linux - Software 5 01-11-2005 03:41 AM
Making a new script Lostboys Slackware 9 09-07-2004 06:11 AM
making a script 'global' fatherg Linux - General 3 08-08-2004 07:40 AM
making my script generic bluecadet Programming 2 01-16-2002 12:31 PM


All times are GMT -5. The time now is 03:51 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration