09-10-2013
Write pid and command name to a txt file while executing a bash script
Hi All,
Just have a requirement, I am executing a bash shell script, my requirement is to catch the pid and job name to a txt file in the same directory, is there anyway to do it? please help me out.
Regards
Rahul
---------- Post updated at 08:42 AM ---------- Previous update was at 08:25 AM ----------
PS: this shell script is executed every 10 seconds in the same shell and I want to immediately capture the pid as soon as this job starts.
2) I have been out of touch with unix for a while so please let me know if the question is incomplete.
Regards
Rahul
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
how can I write a small script to run the following statement and output the result into check_result.txt
select /*+RULE*/ tapname from typetbl where tapname like 'AA%' and rejectcode=9;
Normally, I just type sql and get into SQL> (2 Replies)
Discussion started by: happyv
2 Replies
2. Shell Programming and Scripting
Hello All,
I just want help in coding a simple shell script since i am a newbie for UNIX and i started learning unix and shell scripting basics recently.
I am having a data like this in .txt file.
Product Name : XYZ
Price : 678.1
Best Buy Price : 600
Product Name : ABC
Price : 465... (3 Replies)
Discussion started by: vasanth_123
3 Replies
3. AIX
Hello Everyone,
I am new to shell scripting and also i am very new to AIX machine
I have a question.
I have shell script which contains the follwing
"ps -e |grep $1
echo $2"
i run this schell script by doing this ./startSehllscript 3444 passed with two parameters .
Accroiding my... (4 Replies)
Discussion started by: swati
4 Replies
4. Shell Programming and Scripting
I am writing a script to write to and a sort txt file. After I sort the file I want to add 2 to each line of the file. My script thus far is
#!/bin/bash
cat > /ramdisk/home/stux/unsortedints.out
COUNT=0
FILE =/ramdisk/home/stux/unsortedints.out
for i in {1..100}
do
NUMBER = $
echo $NUMBER... (3 Replies)
Discussion started by: puttyirc
3 Replies
5. Shell Programming and Scripting
Could anyone very kindly help me a simple way to perform the - perhaps - very trivial task of writing the name of a file as first line of that file which is in txt format?
And would be possible to do this recursively for some thousands files in the XY directory?
And, again, add to the simple... (3 Replies)
Discussion started by: mjomba
3 Replies
6. Shell Programming and Scripting
split -l $split_count newfile.txt
for i in $split_files*
do
if test -s $workingdir/$split_files*
then
./<$i.out>
fi
done ... (4 Replies)
Discussion started by: sanjay mn
4 Replies
7. Shell Programming and Scripting
i'm trying to write a bash script that that will automatically extract zip files after the download.
i writed this script
#!/bin/bash
wget -c https://github.com/RonGokhle/kernel-downloader/zipball/master
CURRENDIR=/home/kernel-downloader
cd $CURRENDIR
rm $CURRENDIR/zipfiles 2>/dev/null
... (2 Replies)
Discussion started by: ron gokhle
2 Replies
8. Shell Programming and Scripting
I'm attempting to write a bash script that will create a network between virtual machines. It accepts three arguments: an RSpec that describes the network topology, and two list of machines (servers and clients).
I have a (working) Perl script that I want to call. This Perl script takes an RSpec... (6 Replies)
Discussion started by: mecaka
6 Replies
9. UNIX for Dummies Questions & Answers
Hello experts, I need help writing individual files from a data matrix, with each new file being written every time there is a blank line:
From this
cat file.txt
col1 col2 col3
6661 7771 8881
6661 7771 8881
6661 7771 8881
col1 col2 col3
3451 2221 1221... (6 Replies)
Discussion started by: torchij
6 Replies
10. Shell Programming and Scripting
I want to run commands inside a bash script.
An example is
I want to pass the command in a string as regexp as an argument to the script, then run sed on the bash variable
sed.sh regexp
sed.sh "-i \"s/<p>//g\""
then call
sed "$regexp" $fl (3 Replies)
Discussion started by: Kangol
3 Replies
catch(n) Tcl Built-In Commands catch(n)
__________________________________________________________________________________________________________________________________________________
NAME
catch - Evaluate script and trap exceptional returns
SYNOPSIS
catch script ?varName?
_________________________________________________________________
DESCRIPTION
The catch command may be used to prevent errors from aborting command interpretation. Catch calls the Tcl interpreter recursively to exe-
cute script, and always returns without raising an error, regardless of any errors that might occur while executing script.
If script raises an error, catch will return a non-zero integer value corresponding to one of the exceptional return codes (see tcl.h for
the definitions of code values). If the varName argument is given, then the variable it names is set to the error message from interpret-
ing script.
If script does not raise an error, catch will return 0 (TCL_OK) and set the variable to the value returned from script.
Note that catch catches all exceptions, including those generated by break and continue as well as errors. The only errors that are not
caught are syntax errors found when the script is compiled. This is because the catch command only catches errors during runtime. When
the catch statement is compiled, the script is compiled as well and any syntax errors will generate a Tcl error.
EXAMPLES
The catch command may be used in an if to branch based on the success of a script.
if { [catch {open $someFile w} fid] } {
puts stderr "Could not open $someFile for writing
$fid"
exit 1
}
The catch command will not catch compiled syntax errors. The first time proc foo is called, the body will be compiled and a Tcl error will
be generated.
proc foo {} {
catch {expr {1 +- }}
}
KEYWORDS
catch, error
Tcl 8.0 catch(n)