LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 04-18-2008, 10:24 AM   #1
Joe2003
Member
 
Registered: May 2005
Distribution: Core 4
Posts: 34
Blog Entries: 2

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


Hey

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

Code:
./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

Code:
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:-

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

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Sure thing. Something like this should do it
Code:
while read record
do
 ./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.
 
  


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


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