The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
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

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 01-10-2002
Registered User
 

Join Date: Jan 2002
Location: Texas,US
Posts: 4
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  
Old 01-10-2002
rwb1959's Avatar
Registered User
 

Join Date: Aug 2001
Location: Virginia, USA
Posts: 438
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  
Old 01-10-2002
Registered User
 

Join Date: Jan 2002
Location: Texas,US
Posts: 4
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  
Old 01-10-2002
shaik786
Guest
 

Posts: n/a
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
Yes, kill -2 is the same as [CTRL+C] on the keyboard.
Google The UNIX and Linux Forums
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:49 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0