LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   making a script.. (https://www.linuxquestions.org/questions/linux-newbie-8/making-a-script-440896/)

assasukasse 05-02-2006 10:18 AM

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

BinJajer 05-02-2006 11:22 AM

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...

mbreith 05-02-2006 11:38 AM

You could set it up as a cron job instead of a script.

BinJajer 05-02-2006 11:46 AM

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!

Lotharster 05-02-2006 05:34 PM

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

assasukasse 05-03-2006 03:06 AM

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

muha 06-02-2006 03:17 AM

Google helps:
http://www.faqs.org/docs/abs/HTML/colorizing.html
Quote:

echo -e '\E[37;44m'"\033[1mContact List\033[0m"


All times are GMT -5. The time now is 04:38 AM.