Sponsored Content
Full Discussion: Trapping $! output
Top Forums Shell Programming and Scripting Trapping $! output Post 302151994 by nhatch on Tuesday 18th of December 2007 06:47:28 AM
Old 12-18-2007
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
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

ftp error trapping

Hi I'm hoping I could get some help on the following. I'm writing a script which will in turn create an ftp script then excecute it. eg echo "user $user $pass" > $script echo "cd $remote_dir" >> $script echo "bi" >> $script echo "mput $file" >> $script echo "bye" >> $script ftp -n -i $ip... (1 Reply)
Discussion started by: Bab00shka
1 Replies

2. UNIX for Dummies Questions & Answers

trapping keys

how do i trap enter command entered by a user. actually i am throwing a screen this screen has no input but this screen should be displayes unless and until the user presses the enter key. as the user presses enter key the command prompt should come. how do i achieve this (1 Reply)
Discussion started by: sunil bajaj
1 Replies

3. UNIX for Advanced & Expert Users

Trapping Interrupt From 'ulimit'

I want to know the interrupt passed to a process through 'ulimit' I am running a process which gets killed when the 'ulimit -t' reaches. But after killing the process I want to start another process which would send a message or do some clean up or anything at all. To do the same I am... (5 Replies)
Discussion started by: mrnuttynuts
5 Replies

4. Shell Programming and Scripting

Error Trapping

Hi, Can anybody tell me how to error trap an empty line. If i am asked for a password and I hit enter without entering any text, how do i display an error? Thanks Kev (6 Replies)
Discussion started by: kev112
6 Replies

5. Shell Programming and Scripting

trapping errors while using FTP.

Hello, I have the following shell script to perform ftp: ftp -n $HOST<<EOD quote USER $USER quote PASS $PASS lcd $outputd cd $dir binary put *.zip quit EOD If any error is generated from this script then how to trap the error. For ex: let's say we entered wrong password then the... (5 Replies)
Discussion started by: radhika
5 Replies

6. HP-UX

Trapping the rm command in UNIX

Hi All, Whoever types rm in the command prompt I need to trap the username, the ip address,timestamp and the rm filename(which file they are removing) and write it to the log file. could anyone help me?. Advanced thanks Suma (1 Reply)
Discussion started by: sumas
1 Replies

7. UNIX for Dummies Questions & Answers

trapping errors

I am using unixs script to submit programs (SQRS) and need to trap any time of error that is received once the job finishes. Examples of the type of errors I am getting Error! SQR Failed To Process mkdir: Failed to make directory These are showing up in a log file but I do not want to... (3 Replies)
Discussion started by: TimHortons
3 Replies

8. Shell Programming and Scripting

Trapping Enter command !!

Hi I have written a script which works well .. It's divided into a series of jobs one running after another But on pressing the enter key the whole script goes haywire .. I want a way to trap this enter command and echo it as invalid input .. Any suggestions highly appreciated... Thanks :) (2 Replies)
Discussion started by: ultimatix
2 Replies

9. Shell Programming and Scripting

Trapping exit and continuing

Hello I need to source a script. But that script terminates with a trailing exit. Which exits my script. I'm using bash, and this doesn't work: trap 'echo disabled' EXIT source other_file trap '' EXIT Instead, it calls my trap, but then exits anyway. I could get disgusting and... (4 Replies)
Discussion started by: brsett
4 Replies

10. Shell Programming and Scripting

Error Trapping

Hi, I have one shell script as below while read SegList do if test -s ${SourceFile_Path}/${Segment_List_Temp} then ls -r -1 ${FTP_Path}/${SegList}.DAT.${Datelist}.GZ|cut -d '.' -f2>>${SourceFile_Path}/${List_Temp} echo "IF above statment Fail I want to Create Emtpy File How to Trapp... (3 Replies)
Discussion started by: samadhanpatil
3 Replies
PARALLEL-SCP(1) 														   PARALLEL-SCP(1)

NAME
parallel-scp - parallel versions of scp SYNOPSIS
parallel-scp [OPTIONS] -h hosts.txt local remote DESCRIPTION
pssh provides a number of commands for executing against a group of computers, using SSH. It's most useful for operating on clusters of homogenously-configured hosts. parallel-scp copy files in parallel to a set of machines. OPTIONS
-r --recursive recusively copy directories (OPTIONAL) -h --hosts hosts file (each line "host[:port] [user]") -l --user username (OPTIONAL) -p --par max number of parallel threads (OPTIONAL) -o --outdir output directory for stdout files (OPTIONAL) -e --errdir output directory for stderr files (OPTIONAL) -t --timeout timeout (secs) (-1 = no timeout) per host (OPTIONAL) -O --options SSH options (OPTIONAL) -v --verbose turn on warning and diagnostic messages (OPTIONAL) EXAMPLE
The following example runs hostname on three machines (IPs or hostnames) specified in the file ips.txt using login irb2 and saves the output in /tmp/foo. # parallel-scp -h ips.txt -l irb2 /etc/hosts /tmp/hosts Success on 128.112.152.122:22 Success on 18.31.0.190:22 Success on 128.232.103.201:22 ENVIRONMENT
All four programs take similar sets of options. All of these options can be set using the following environment variables: o PSSH_HOSTS o PSSH_USER o PSSH_PAR o PSSH_OUTDIR o PSSH_VERBOSE o PSSH_OPTIONS SEE ALSO
parallel-ssh(1), parallel-slurp(1), parallel-nuke(1), parallel-rsync(1), ssh(1), scp(1), AUTHOR
Brent N. Chun <bnc@theether.org> COPYING
Copyright: 2003, 2004, 2005, 2006, 2007 Brent N. Chun NOTES
1. bnc@theether.org mailto:bnc@theether.org 03/30/2009 PARALLEL-SCP(1)
All times are GMT -4. The time now is 07:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy