LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-09-2010, 10:32 AM   #1
nesrin
LQ Newbie
 
Registered: Nov 2010
Posts: 15

Rep: Reputation: 0
entering automatically the value that the software asks during processing of a file


Hello,
I use the below loop to process each file (listed in a text file) with a software. During processing the software asks me to enter a value and continues processing of that file after i enter the value. I have those values stored in a text file "myfile". what i want is to get the values directly from myfile when the software asks
"please enter the title:"

I dont want to enter them all manually. But i could not figure out how to code this in Bash script.

Code:
for ((i=1,i<=$NR,i++)); do

--command of the software comes here--

done
Thanks in advance
regards
 
Old 12-09-2010, 10:38 AM   #2
alunduil
Member
 
Registered: Feb 2005
Location: San Antonio, TX
Distribution: Gentoo
Posts: 684

Rep: Reputation: 62
To pass a file as input to a command you can use the input redirection '<' (e.g. echo < stuff.txt).

Regards,

Alunduil
 
1 members found this post helpful.
Old 12-10-2010, 04:06 PM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
To rephrase your question, you have one program that you want to run iteratively, and on each iteration, supply commandline arguments to that program. The commandline arguments are to be read from a file, each time taking the next argument(s) in the list.
If so, then you seem to be mostly on the way to success already.

This will work if the data for each iteration is on one line of the argument data file.

Code:
while read arg1 arg2; do
   echo "The args are : [1]\"$arg1\"  [2]\"$arg2\"
done < datafile
--- rod.

Last edited by theNbomr; 12-13-2010 at 02:10 PM.
 
1 members found this post helpful.
Old 12-10-2010, 07:42 PM   #4
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 952

Rep: Reputation: 217Reputation: 217Reputation: 217
In *nix, most system utilities follow the standard of permitting redirected input as source, but it is not axiomatic that your application software will do the same (allow input redirected). Certainly in a GUI environment, it should have been specifically programmed before hand.Try anyway with your software.

But I think that your software asks a series of questions like "Please enter the title:", .. and so on in a specified sequence and that is what you would put in the text file.

Try with the following:
mysoftware < myfile.txt

Details about the software might help.
 
1 members found this post helpful.
Old 12-13-2010, 04:50 AM   #5
nesrin
LQ Newbie
 
Registered: Nov 2010
Posts: 15

Original Poster
Rep: Reputation: 0
thank you all,
simple input redirection "<" solves my problem actually I thought it is more complicated. thanks a lot.
@ theNbomr: thanks for rephrasing my question. That is exactly what i meant, and meanwhile i am also learning how to formulate questions better.
@ AnanthaP: I am using Gamma remote sensing software, and it works well with redirection.
 
  


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
Chinese character entering software linuxmandrake Linux - Software 3 03-16-2010 10:39 PM
Create a script that asks the user for a file and then appends the date to the file larry5757 Linux - Newbie 2 12-04-2009 06:33 AM
proftpd asks for rsa key everytime, can it be done automatically? GUIPenguin Linux - General 0 05-19-2006 12:49 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

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