The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
rcp error trapping in rsh vvejendla Shell Programming and Scripting 2 11-21-2005 11:29 PM
trapping errors while using FTP. radhika Shell Programming and Scripting 5 05-27-2005 08:55 AM
Error Trapping kev112 Shell Programming and Scripting 6 05-25-2005 02:37 AM
ftp error trapping dhawkjrscripter UNIX for Dummies Questions & Answers 1 04-15-2005 05:58 PM
ftp error trapping Bab00shka UNIX for Dummies Questions & Answers 1 04-02-2002 12:21 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-18-2007
nhatch nhatch is offline
Registered User
  
 

Join Date: Aug 2002
Location: London, England
Posts: 85
Trapping $! output

hey all,

I have a script that creates and then distributes html files via scp on a 60 second cycle. On occasions the scp will hang and not complete with the cycle.

When running the scp command in the back ground it returns the PID. How do I trap $! in the script?

Code:
job=`echo $!` returns an error. 
-bash-3.00$ job=`echo $!` 
-bash: !`: event not found

What I want to be able to do is monitor how long the scp runs for, if it is still running 2 minutes after starting then it is hung (can't just ps for the scp command as the scp script is used by multiple applications).

Any ideas?

Cheers,
Neil
  #2 (permalink)  
Old 12-18-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,957
just use it as $!

Code:
a=$!
  #3 (permalink)  
Old 12-18-2007
nhatch nhatch is offline
Registered User
  
 

Join Date: Aug 2002
Location: London, England
Posts: 85
Easy....feel a bit stupid now.


Cheers,
Neil
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:19 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0