It does not make sense to put CTL-D inside a script file for purposes of exiting the script. As previously suggested, use "exit".
If you want to enter CTL-D into the file, using vi, just use CTL-V CTL-D sequence.
When a program is receiving input from stdin, you can enter CTL-D at the beginning of a line to signal "end of file". I think that's what you're getting mixed up. "end of file" for a Unix file is just signaled by end of file (no more content), period. Putting CTL-D in the middle of the file does not signal "end of file". You can verify with a test. Put CTL-D somewhere toward the top of the file, and cat the file. The whole file is shown, not just the part before the CTL-D.
Can you tell us what exactly you are trying to do?
If you are trying to instruct a script to handle certain task while it is already running, then you can use trap to catch a user-defined signal and perform an action.
For example, here is a script:
If you run this script on a session and from another session if you send a USR1 signal to the running script PID, the trap argument will be executed:
Modify it as per your requirement. I hope this helps.
Hey All,
I am writing one script using expect, that script which is used in spawn will accepts only 1. Enter 2. Ctrl+c
Press Control-C to exit, Enter to proceed.
Could some one share some thoughts to send the above user inputs in linux expect block ?
Thanks,
Sam (0 Replies)
Hi,
Am trying to transfer file via FTP using expect script from server to client
i need to interrupt the file transfer between server and client
Please help what should used in expect code..
I used
send "ctrl+c\r"
expect "Aborted"
but that didnt work.. I need what should... (3 Replies)
im trying to make a trap signal 2 (ctrl c) in a bash script
if a user presses ctrl c while running the script it should display an error message but not quit the bash script just yet. User will have to press "enter" to quit
This is what i have so far
#trap trap_control 2
#while true
#do... (6 Replies)
Hi i want to know how can i write a script to check if any changes are made and send an alert in crontabs . i am using .ksh file extension for writing scripts. (3 Replies)
I'm trying to do a program that makes activate an signal (SINGALARM) when the next child of a son appears but this not works.
I have to caught the next child o the other (pid), to send a singnal which inform a menssage.
It's anything worng in the code?
thanks.
the code:
#include... (2 Replies)
Greetings,
I am writing an Expect script to automate multiple processes on an HP-UX system. Everything has gone fine so far but I now have run into a problem. One of the processes that I'm trying to automate requires the key combination of ctrl break and I have so far been unable to figure out... (1 Reply)
Hello
I have a master startup script (let's call it myScript) that displays a menu from which the user can start/stop several instances of a server. When I issue the start command for one of the servers from the menu and then exit myScript through the provided mechanism (enter "q" in this case),... (2 Replies)
I wrote a ksh script for Helpdesk. I need to know how to disable ctrl-c,ctrl-z,ctrl-d..... so that helpdesk would not be able to get to system prompt :confused: (6 Replies)