- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: cntrl-d in shell script
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
Forums
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
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-27-2007 12:54 AM
тАО12-27-2007 12:54 AM
What signal I will do the cntrl-d function in a shell script ?
I tried exit, exit 1, but no luck
Vijay
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-27-2007 01:14 AM
тАО12-27-2007 01:14 AM
Re: cntrl-d in shell script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-27-2007 01:28 AM
тАО12-27-2007 01:28 AM
Re: cntrl-d in shell script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-27-2007 01:33 AM
тАО12-27-2007 01:33 AM
Re: cntrl-d in shell script
The ascii code for EOF(ctrl+D) is 0x1A, one way would be this:
perl -e "print \"\\x1A\";" | blah_command_to_recieve_it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-27-2007 03:00 AM
тАО12-27-2007 03:00 AM
Re: cntrl-d in shell script
You can use "trap exit ..." but that will only work if you have an interactive shell. Or when you get to the end of your shell script.
Note: One shell script can read stdin N times, each terminated by the the EOF of the disk file or control D on a terminal.
>Mridul: The ascii code for EOF(ctrl+D) is 0x1A
No, the code is 0x04, see ascii(5). 0x1a, control-Z is the DOS EOF.
>one way would be this:
perl -e "print \"\\x1A\";" | blah_command_to_receive_it
This won't work. Control D is only valid for terminals. Not files nor pipes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-27-2007 09:18 PM
тАО12-27-2007 09:18 PM
Re: cntrl-d in shell script
Let me tell you what I want to do, I have script which will send an Email if my ignite fails,
The script stops at this line, I want to come out from this line..
mailx -s "`hostname`: no tape loaded - ignite failed" vijay@xyc.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-27-2007 10:01 PM
тАО12-27-2007 10:01 PM
Re: cntrl-d in shell script
mailx -s "`hostname`: no tape loaded - ignite failed" vijay@xyc.com
You need to provide stdin for the message body. You can either use echo, a here document or /dev/null:
$ echo hi | mailx -s "ho" ...
$ mailx -s "stuff" ... < /dev/null
$ mailx -s "more stuff" ... <
EOF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-27-2007 10:10 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-28-2007 12:43 AM
тАО12-28-2007 12:43 AM
Re: cntrl-d in shell script
Cheers
Vijay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-28-2007 12:44 AM
тАО12-28-2007 12:44 AM
Re: cntrl-d in shell script
Cheers
Vijay