Reading runtime arguments from a file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Reading runtime arguments from a file
# 1  
Old 08-18-2005
Reading runtime arguments from a file

Hi All,

I am running a script which wud take a long time to complete execution ... In between, it asks for yes/no sort of confirmation from user for doing some acivities .... Now that I dont want to wait till the script executes upto this point where it needs user confirmation, is there any way by which I can store my confirmations (all Y's or N's whatever it is) in a file and tell the script to take the run time arguments from this file as and when it needs ...

I am sure that I have read of some command by which this can be done but not able to recollect it at present ..

Can any one help me here ?

Thanks in advance,

SNS
# 2  
Old 08-18-2005
Did you try expect ?

Vino
# 3  
Old 08-18-2005
Redirect stdin
Code:
command < responsefile

or a here document:
Code:
command <<EOF
y
n
n
y
n
y
EOF

# 4  
Old 08-24-2005
Hi,

I dont have expect in my machine .... the here document shud be helping .. but not working ... i will make my qn more particular ...

I tried this command where I need to give my resonses before itself may be from a file or something like that .... In this case I can avoid -n1 option for achieving this ... but wanted to know why ( < responsefile ) and here document ( << EOF as specified in previous reply thread) do not work here ...

$ ps -eaf | grep FRAUD | awk -F" " '{print $2}'| xargs -n1 -t -p kill;
kill 18919?...n
kill 14658?...n

Thanks,

SNS
# 5  
Old 08-24-2005
Look at how xargs is used. It is already reading from stdin. The -p makes it open /dev/tty to talk with the user. That is why the here document won't work.

What you are try to do looks dangerous. So you are sure that lines 1, 4, and 6 are guaranteed to be the ones you want to kill? Well:
$ ps -eaf | grep FRAUD | awk -F" " '{print $2}' | sed -n '1p;4p;6p' | xargs kill
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Reading structured arguments

I am passing an argument to a C++ program which is going to look like I need to get the integers into arrays a, b, c, d with a= 12,12,34,2,12 b= 34,4,2,1,23 c= 5,5,4,4,13 d= 6,6,6,6,5 (5 Replies)
Discussion started by: kristinu
5 Replies

2. Shell Programming and Scripting

Multiple runtime arguments

I am passing 3 runtime arguments to a shell script $path crtl1 crtl2 the crtl files contains data(filename|date|count) filename.txt|02/05/2010|10 The path contains the original data file,the code should fetch (filename|date|count) from original data file and it should match... (7 Replies)
Discussion started by: Prashanth B
7 Replies

3. Shell Programming and Scripting

Reading arguments for a shell script from file

I have a shell script that takes 2 arguments. I will have to execute this script multiple times with different values for the arguments. for example, ./shscript env1 value1 ./shscript env1 value2 ./shscript env2 value3 ./shscript env3 value4 ./shscript env1 value5 ./shscript env3... (24 Replies)
Discussion started by: goddevil
24 Replies

4. Shell Programming and Scripting

Reading arguments but exclusing some

I have a tcsh script which I pass arguments to. I want to store all the arguments except for the options. Currently I am using the line below, however I want to also exclude and variation of them (e.g. whether any letter is uppercase or lower case) Is there a neat way to do it? set... (0 Replies)
Discussion started by: kristinu
0 Replies

5. Shell Programming and Scripting

Passing arguments at runtime

Hi .. Can any one please tell how to pass argument to shell script at runtime? I want to implement funcnality just like bc, where we can provide input while script is running and can be used later in the same script. Thanks in advance... (1 Reply)
Discussion started by: kunjalhg
1 Replies

6. Shell Programming and Scripting

How to give runtime arguments to different program

I have a shell script that is attempting to call a c program. I call the c program with ./dictool dictool accepts arguments at runtime. It works by prompting the user for various commands, acting on those commands, spitting out an output, and then prompting for more commands. My question is,... (1 Reply)
Discussion started by: aarongoldfein
1 Replies

7. Shell Programming and Scripting

reading in arguments with spaces

I want to be able to read in input which contain spaces and put that into an array. Each field should be delimeted by a space and should be a different array element. However I cant get it to work. any tips? read input //type field1 field2 field3 echo "$input" array="$input" Thanks in... (11 Replies)
Discussion started by: Calypso
11 Replies

8. UNIX for Advanced & Expert Users

connect problem for sctp socket (ipv6 socket) - Runtime fail Invalid Arguments

Hi, I was porting ipv4 application to ipv6; i was done with TCP transports. Now i am facing problem with SCTp transport at runtime. To test SCTP transport I am using following server and client socket programs. Server program runs fine, but client program fails giving Invalid Arguments for... (0 Replies)
Discussion started by: chandrutiptur
0 Replies

9. Shell Programming and Scripting

passing runtime arguments to a shell script...

hi I am new to shell programming.....my question is while running one of my shell program it stops in between to accept input from the user and proceeds furthur after giving input....I want to know whether I can set this input through some files so that the shell acript reads the input from the... (10 Replies)
Discussion started by: santy
10 Replies

10. Shell Programming and Scripting

Bash: Reading 2 arguments from a command line

If no arguments are entered I wanna be able to read 2 arguments, i have done like this but it doesnt work: x=0 until #loop starts do if ; then echo No arguments were entered, please enter 2 arguments. read $1 $2 elif || ; then echo $#... (0 Replies)
Discussion started by: Vozx
0 Replies
Login or Register to Ask a Question