![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Maintain full path of a script in a var when sourcing it from a different script | mrbluegreen | Shell Programming and Scripting | 4 | 03-19-2008 07:31 PM |
| help me in sending parameters from sqlplus script to unix shell script | Hara | Shell Programming and Scripting | 2 | 01-29-2008 12:31 PM |
| Shell Script: want to insert values in database when update script runs | ring | Shell Programming and Scripting | 1 | 10-25-2007 12:06 AM |
| Modify Perl script to work with txt - Permissions script | joangopan | Shell Programming and Scripting | 1 | 09-12-2007 08:38 PM |
| check in unix shell script so that no one is able to run the script manually | adi_bang76 | Shell Programming and Scripting | 1 | 11-16-2006 07:43 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
how to cntl^c in a script
can anyone please let me know how I can terminate a command Ex:"truss filename.truss.txt -p pid" after letting it run for 2sec in a korn shell script.In other words how can we emulate cntl^c in a script??
|
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Assuming you executed the truss command in
background in the script, you can try... ... truss ... & TRUSSPID=$! sleep 120 kill -2 $TRUSSPID ...basically, send SIGINT to the PID of the truss process. Note however, I have not tested this. |
|
#3
|
|||
|
|||
|
Thanks a lot for you prompt response..
I am not executing this command in the background. Can I do the following?? mycomm='truss filename.truss.txt -p pid' sleep 2 kill -2 $mycomm By the way,Is kill -2 equivalent to cntl^c on keyboard?? |
|
#4
|
|||
|
|||
|
You can not do what you've typed to achieve what you want, as they will be executed in a sequence, not parallelly. Try this i
nstead: Code:
(sleep 2; kill -2 `ps | awk '{print $6" "$1'} | grep "^truss" | awk '{print $2}'`) | truss filename.truss.txt -p pid
|
|||
| Google The UNIX and Linux Forums |