[SOLVED] entering automatically the value that the software asks during processing of a file
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.