- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Korn Help: need to enter two "y"s onto a command i...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-17-2015 01:02 PM
тАО11-17-2015 01:02 PM
Korn Help: need to enter two "y"s onto a command in a script
I have a script and it will be basically repeating to run a command on a lot of different parameters, then this command requires to enter two "y"s, and then enter after each "y".
What can I do to allow the script to enter a "y", and then RETRUN, then one more "y" again, then RETURN?
Tried differnet ways, but could not figure that out. Appreciate your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-17-2015 04:23 PM
тАО11-17-2015 04:23 PM
Re: Korn Help: need to enter two "y"s onto a command in a script
> I have a script and it will be basically [...]
With my weak psychic powers, I can't see your script, and what it
"basically" does is probably much less important than what it _actually_
does.
> [...] Appreciate your help!
Perhaps, but you might waste less of everyone's time if you didn't
make your readers guess what you're doing. As usual, showing actual
commands with their actual output can be more helpful than vague
descriptions or interpretations. Examples of useless descriptions:
run a command on a lot of different parameters
this command
to enter a "y"
Tried [different] ways
For a good time, try a Web search for:
how to ask a technical question
Then, do some reading. Then, try asking a question which a non-psychic
might have some chance of being able to answer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-18-2015 05:33 AM - edited тАО11-18-2015 05:36 AM
тАО11-18-2015 05:33 AM - edited тАО11-18-2015 05:36 AM
Re: Korn Help: need to enter two "y"s onto a command in a script
There is a program in HP-UX called yes. (see: man yes)
Since there are no details about how you are asking the question in the script, you'll have to figure out how to connect the yes program to the question. If your script only expects the "y" then you can feed the answers like this:
yes | script_name <commandLine_stuff>
or
yes | head -2 | script_name <commandLine_stuff>
BTW: to see it working:
$ yes | head -2 y y $ yes no | head -3 no no no
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-18-2015 10:02 AM
тАО11-18-2015 10:02 AM
Re: KSH Help: need to enter two "y"s onto a command in a script
You could also use a here-doc where you supply the input:
script <<EOF
inputs ...
EOF
Unless you quote the EOF word, $ expansions are done in your inputs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-18-2015 11:51 AM
тАО11-18-2015 11:51 AM
Re: KSH Help: need to enter two "y"s onto a command in a script
cat sani.sh
for i in `cat list`
do
ssh user_id@ip command op1 opt2 -c 6 $i
done
to beigining with, I just did one interactive execution, and it doesn't work.
$ yes | head -2 | ssh user_id@ip command op1 opt2 -c 6 0a.16
Would you like to continue (y/n)? Please answer yes or no.
Would you like to continue (y/n)?
It did not accept what being fed.
Hope it is clear this time. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-18-2015 01:36 PM
тАО11-18-2015 01:36 PM
Re: KSH Help: need to enter two "y"s onto a command in a script
> to beigining with, I just did one interactive execution, [...]
That's a good way to start.
> $ yes | head -2 | ssh user_id@ip command op1 opt2 -c 6 0a.16
What happens without the "yes | head -2 | " part?
> Would you like to continue (y/n)? Please answer yes or no.
> Would you like to continue (y/n)?
>
> It did not accept what being fed.
From here, it's not clear who "It" is. Are the "Would you like to
continue" questions coming from "ssh" or from "command" (whatever that
might be)? If you "ssh" (as "user_id") to "ip", can you make "command
[...]" work interactively?
> Hope it is clear this time. [...]
Better, but not good.
It might be helpful if you said what the operating system at "ip" is,
and what "command" is. If the program which is asking the questions is
not reading from stdin, then you may not be able to pipe data into it.
There may be other ways to make this kind of thing work, but with no
real information on what "this kind of thing" actually is, you're asking
for more guesswork (again).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-18-2015 02:06 PM
тАО11-18-2015 02:06 PM
Re: KSH Help: need to enter two "y"s onto a command in a script
If the remote end is HP-UX, then you might try something like this instead:
ssh user_id@ip yes | head -2 | command op1 opt2 -c 6 0a.16
This way the "yes" is run on the destination rather than the source.
But that's just a shot in the dark since we're not sure about the destination.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-18-2015 03:24 PM
тАО11-18-2015 03:24 PM
Re: KSH Help: need to enter two "y"s onto a command in a script
> ssh user_id@ip yes | head -2 | command op1 opt2 -c 6 0a.16
>
> This way the "yes" is run on the destination rather than the source.
Unfortunately, that way, "yes" is the _only_ thing which is run on
the remote system. For example (on a Mac or two):
mba$ uname -n
mba.local
mba$ ssh pro3 pwd | uname -n
mba.local
With some quotation, more of the pipeline can be run on the remote
system:
mba$ ssh pro3 'pwd | uname -n'
pro3.antinode.info
> But that's just a shot in the dark since we're not sure about the
> destination.
Among many other things about which we have no useful information.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-21-2015 02:13 PM - edited тАО11-21-2015 02:16 PM
тАО11-21-2015 02:13 PM - edited тАО11-21-2015 02:16 PM
Re: KSH Help: need to enter two "y"s onto a command in a script
Try using ssh -n to prevent stdin from being eaten up:
for host in $(< list); do
ssh -n user_id@ip command op1 opt2 -c 6 $host
done
If you need that yes(1) solution, you would need to put it inside the ssh command pipeline.