- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Shell Script in non-prompt mode
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
тАО12-09-2002 11:08 AM
тАО12-09-2002 11:08 AM
How do I get place the script in non-interactive mode so that it automatically answers "y" and hits carriage return after each prompt instead of waiting for a user input. Please look the script below.
===========================================
for i in `vgdisplay -v vgtest| egrep "LV Name"|awk '{print $NF}'`
do
lvreduce $i
done
==============================================
I get the following prompt after before LV removal.
=====================
The logical volume "/dev/vgtest/lvol1" is not empty;
do you really want to delete the logical volume (y/n) :
========================
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-09-2002 11:10 AM
тАО12-09-2002 11:10 AM
Re: Shell Script in non-prompt mode
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-09-2002 11:35 AM
тАО12-09-2002 11:35 AM
Re: Shell Script in non-prompt mode
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-09-2002 05:46 PM
тАО12-09-2002 05:46 PM
SolutionFor this command, there's the -f option as already pointed out. When the command doesn't have an option, most can be scripted by using "here-document" syntax. You simply redirect standard input from the script. Example:
command <
something
something else
n
EOF
In this example, "y" is passed as input the first time "command" expects input. The second time, a null response is input (the blank line is just as if you entered CR from the keyboard). The third time "something" is input. And so on...
For here-documents, there are to be no leading spaces for any input line nor the ending "word" (EOF in this example). You can use leading tabs if you specify the here-document by using <<- instead of <<. Also, EOF isn't special. You can use any word. See man sh-posix for more info.
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-09-2002 11:05 PM
тАО12-09-2002 11:05 PM
Re: Shell Script in non-prompt mode
Just for information because you've got some good answers already (-f option of lvreduce and redirecting input using <<), but there is also a funny tool that you can use when you need a lot of 'y' answer. It's 'yes', which sends 'y' followed by a linefeed repeatedly (or any other string if you want). So just pipe it to your script :
yes | rm -i a b
will answer yes to all suppress confirmation (I know that in this case 'rm a b' would be better :^) ).
Or
yes good | foo
will answer good to all foo inputs.
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-10-2002 06:17 AM
тАО12-10-2002 06:17 AM
Re: Shell Script in non-prompt mode
lvreduce cannot be performed if the volume group is activated in shared mode.
Even if you get feed the y to the program if you try it in certain circumstances it will squawk.
more
lvreduce asks for confirmation before deallocating logical extents if
the -f option is omitted.
redundant post? Perhaps.
Steve
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-10-2002 07:13 AM
тАО12-10-2002 07:13 AM
Re: Shell Script in non-prompt mode
Jean- your suggestion works on rm command
but when I do a lvremove on LV
y | lvremove /dev/vgmass/lvol1
it gives me "Bad Input Parameter"
Darrell-yours worked perfectly with the EOF script
Steve, Tom, Pat, thanks to all with lvreduce option but I was looking for an option to be used with other commands as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-10-2002 07:20 AM
тАО12-10-2002 07:20 AM
Re: Shell Script in non-prompt mode
Strange, I give you the execution on my system :
/.root# lvcreate -L 12 vg00
Logical volume "/dev/vg00/lvol13" has been successfully created with character device "/dev/vg00/rlvol13".
Logical volume "/dev/vg00/lvol13" has been successfully extended.
Volume Group configuration for /dev/vg00 has been saved in /etc/lvmconf/vg00.conf
/.root# yes | lvremove /dev/vg00/lvol13
The logical volume "/dev/vg00/lvol13" is not empty;
do you really want to delete the logical volume (y/n) : Logical volume "/dev/vg00/lvol13" has been successfully removed.
Volume Group configuration for /dev/vg00 has been saved in /etc/lvmconf/vg00.conf
So it seems to work, but I use 'yes', not 'y'. Anyway it was just for fun because in your case I would also have redirected input using << :^)
Regards.