Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 04-18-2008, 10:24 AM   #1
Registered: May 2005
Distribution: Core 4
Posts: 34
Blog Entries: 2

Rep: Reputation: 15
is a bash script right for this?


I have writen some code that im using to test a uni project. Its just abit of C that accepts some parameters, the parameters are the test data, eg

./TestProgram test data here
My code works fine, I know want to add a level of repeatability to the application without modifying the code. I have a file, on each line is a new set of parameters

test data 1
test data 2
test data 3
is there a method in batch scripting to envoke a system call based on each line of a text file, therefore in my exaple, the following commands would be called:-

./TestProgram test data 1
./TestProgram test data 2
./TestProgram test data 3
Old 04-18-2008, 12:13 PM   #2
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,397
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Sure thing. Something like this should do it
while read record
 ./TestProgram $record
done < YourFileWithTestData
This reads the test data file, line-at-a-time style, into the variable $record, and uses $record as the argument to TestProgram, looping once for each record in the data file.
--- rod.


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
passing variable from bash to perl in a bash script quadmore Programming 6 02-21-2011 05:11 AM
set variables in a bash script; ansi PS1 color script donnied Programming 4 11-21-2007 12:33 PM
Bash script to create bash script jag7720 Programming 10 09-10-2007 08:01 PM
[bash] having trouble debugging this bash script. jons Programming 4 02-08-2007 07:51 AM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 01:20 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:50 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration