- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Control-C in here document (scripting)
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
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
тАО04-16-2004 12:27 AM
тАО04-16-2004 12:27 AM
How do I sent a control-c (^c)
from a here document within a script.
#! /usr/bin/ksh
function SWITCH {
exec >> //log/test.log 2>&1
set -x
date
exec telnet ${1} << EOF
admin
login
^c (not working like this)
date; portperfshow 30
EOF
}
SWITCH
SWITCH
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2004 12:49 AM
тАО04-16-2004 12:49 AM
Re: Control-C in here document (scripting)
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2004 01:12 AM
тАО04-16-2004 01:12 AM
Re: Control-C in here document (scripting)
Same problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2004 01:33 AM
тАО04-16-2004 01:33 AM
Re: Control-C in here document (scripting)
If it is to stop something running, and you want the result of the date and portperfshow command then can't you just use a different account that doesn't start this application in the .profile and perhaps use remsh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2004 01:51 AM
тАО04-16-2004 01:51 AM
Re: Control-C in here document (scripting)
The message is this:
Password:
Please change your passwords now.
Use Control-C to exit or press 'Enter' key to proceed.
If enter the we need to change the passwords.
We don't want to do that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2004 01:58 AM
тАО04-16-2004 01:58 AM
Re: Control-C in here document (scripting)
You might consider using "expect" instead.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2004 01:58 AM
тАО04-16-2004 01:58 AM
Re: Control-C in here document (scripting)
As far as I know to insert a control character in vi, when you are in insert mode type ctrl v and then ctrl c and ^C will be recognised.
Hope this helps,
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2004 08:54 AM
тАО04-16-2004 08:54 AM
SolutionWhen you're doing it interactively, the effect of pressing ^C is to send SIGINT to the foreground process group.
This is handled directly by the tty driver, which delivers the signal (similarly for other control combinations, like ^Z, sending SIGTSTP -- this is configurable via stty(1)).
When reading from a heredoc, there is no tty involved (stdin is a pipe, not a tty device), so the raw ^C character gets passed through to login. No signals are sent.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2004 09:09 AM
тАО04-16-2004 09:09 AM
Re: Control-C in here document (scripting)
When telnet(1) receives a SIGINT from the terminal driver, it sends an _out of band_ sequence indicating the interrupt to the remote telnetd, which then sends a SIGINT to its own children (or does the equivalent on that OS).
As before, including a literal ^C in stdin will just result in the remote process recieving a literal ^C, rather than the expected SIGINT.
I'm not sure there's an easy solution -- you'd need to write something to parse telnet(1)'s stdout and send a SIGINT to it at the appropriate moment.
It might be less work to change the admin password by hand once so it doesn't complain.
If it's possible, I'd really recommend using SSH with public key authentication instead of telnet -- it's much more secure and you don't have to worry about passwords then.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-18-2004 05:42 PM
тАО04-18-2004 05:42 PM
Re: Control-C in here document (scripting)
So I ended up changing the passwords.
Thanks for the suggestions.
Clemens