passing input into a cmd line that's waiting for a response


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers passing input into a cmd line that's waiting for a response
# 1  
Old 07-23-2012
passing input into a cmd line that's waiting for a response

Hi,

I am writing a little script to update a parameters on JMQ. however the JMQ requires a "y" confirmation to be input as part of the cmd I am running. However I want run this script to offline with no input from a user.

it works if a I create a file with with just y in it and pass that in but how do a do it with out creating the extra yes.txt file?

%> ./imqcmd <bunch of switches> < yes.txt <--- works
%> ./imqcmd <bunch of switches> < "y" <----- how do I do this properly so there's no need for the yes.txt
# 2  
Old 07-23-2012
Use a here-string:
Code:
%> ./imqcmd <bunch of switches> <<<y

This User Gave Thanks to cero For This Post:
# 3  
Old 07-23-2012
Even if you put on quotes < still expects a filename so that won't work.

There's a few ways.
Code:
echo "Y" | ./script

Code:
./script <<EOF
Y
EOF

Note the ending EOF is at the beginning of the line and must be at the beginning of the line.
This User Gave Thanks to Corona688 For This Post:
# 4  
Old 07-23-2012
Thanks - it's been annoying me for an hour that one.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell read command is not waiting for user input

Hi, i am working on one automation , for that i have writing one shell program that take user input in "while read line" block. but read command is taking value that is readed by While block. while read line; do command 1; command 2 echo -n "Do you want to continute > " read rsp... (2 Replies)
Discussion started by: ranvijaidba
2 Replies

2. Shell Programming and Scripting

How to detect that foreground process is waiting for input?

Hi, I have to create a script (ksh or perl) that starts certain number of parallel jobs (another scripts), each of them runs as a foreground process in a separate session. Plus I start monitoring job that has to determine if any of those scripts is expecting input from operator, and switch to... (4 Replies)
Discussion started by: andyh80
4 Replies

3. UNIX for Dummies Questions & Answers

input URL into cmd with a alias

I want to run wget "URL" -SO /dev/null 2>&1 | grep "HTTP/\\|Age:\\|Last-Modified:" but I want a alias so I can just type mywget and the URL and it will put the url in the right place and give me the output that I want without having to type that over and over again.:wall: I am newbie to all... (2 Replies)
Discussion started by: splitradius
2 Replies

4. Shell Programming and Scripting

How to skip command if it is hanging while waiting for response

Hello, I have a script that contains the command "whois 1.2.3.4" Sometimes this command takes far too long to produce any output and as a result the rest of the script is not executed. Can anyone suggest a method so that if no output is produced after say 2 seconds the script skips that... (2 Replies)
Discussion started by: colinireland
2 Replies

5. UNIX for Dummies Questions & Answers

Send email with attachment and body : mailx , waiting for input , signal Control D

Hi, I am trying to send email with attacment and body using "mailx" (cat body.txt; uuencode attach.txt) | mailx -s "Attachment" abc@xyz.com When i type this command, the shell is still waiting for me to enter something in standard input and press control D before it sends a mail and... (2 Replies)
Discussion started by: aliaszero
2 Replies

6. Shell Programming and Scripting

SQL PLUS Command 'ACCEPT' is not waiting for user input with sh shell script

Dear All, The sqlplus 'Accept' command is not waiting for user input when I include the command within a shell script. Note: The 'Accept' command is working fine if I execute it in a SQLPLUS Prompt. Please fins the below sample script which i tried. SCRIPT: -------- #!... (4 Replies)
Discussion started by: little_wonder
4 Replies

7. Programming

How to take input from cmd line into file

Hi, I want to be able to write a simple program that takes in input from the command line. I;m am at the level of getchar and putchar. Any examples would be a great help thanks. I intend/prefer also to use the pipe command | eg: input | file1 ---------- Post updated at 04:08 PM ----------... (4 Replies)
Discussion started by: metros
4 Replies

8. UNIX and Linux Applications

waiting for ssh response for seconds

Hi All, I have to make an alert that'll wait for ssh response from the server for certain seconds, if no response is there in between it'll raise an alarm. Havn't found any option for this yet, pls. help if anyone knows abt this. Any suggestion is welcome. :) Best Regards, VG (3 Replies)
Discussion started by: vguleria
3 Replies

9. Programming

Detecting if command is waiting for input

Hi, After doing a fork and executing a shell, we execute (third party) commands which are essentially non-interactive. But some of them ask for input, under some (unforeseeable) circumstances. When this happens we go on waiting for output. Their is timeout, of course, but we don't seem to know... (5 Replies)
Discussion started by: slash_blog
5 Replies

10. Shell Programming and Scripting

read-waiting for user response

Would there be any reason for why a 'read ans' would not wait for a user's response (i.e user has to hit a key to continue)? I know for sure that it is doing everything else in that part of my 'if' statement but it doesn't wait for me to hit a key before continuing. The strange thing is that... (4 Replies)
Discussion started by: giannicello
4 Replies
Login or Register to Ask a Question