Sponsored Content
Top Forums Shell Programming and Scripting [Solved] Unable to mailx new $pid for a script restart Post 302817861 by olyanderson on Thursday 6th of June 2013 03:02:02 PM
Old 06-06-2013
[Solved] Unable to mailx new $pid for a script restart

Ill try to make this brief:

I am trying to get the script below to run another script defined as BATNAM.
The script runs fine, does what i designed it to do, however...

I would like it to mailx the NEW $pid that was restarted.

This script is supposed to go in crontab as root, and run by the min checking if $pid exists.

Lastly, should i try a diff approach, maybe a "while" or "until"? rather than "if/then/else"

I have tried sleep 10, as it does take more than 7 seconds for the script to show up in ps -ef|grep myusername.

could you pls review the code below, and make suggestions.
This is a simple syntax issue and I am unable to find it.

I am on hpux / /usr/bin/sh, and I have root if necessary.

thanks!
Code:
#!/usr/bin/sh -x
# set the locals
stty intr '^c'

# set the vars
BATDIR="/usr/script8/batch"             # batch dir
BATNAM="bat_fstsi61c.sh"                # batch process file
BATPF="bat_fstsi61.pf"                  # batch to grep
BATSVC="SIGTEST"                        # mail topic
BATPF="bat_fstsi61.pf"                  # batch to grep
SERVER="PHANTOM"                        # servername here
SDIR="/apps/sigmon/dvl/fst61"           # sigmon dir
SIN="$SDIR/in"                          # in dir
SPROC="$SDIR/proc"                      # proc dir
SLOG="/usr/script8/batch/LOGS"          # log dir
SMAIL="/usr/script8/batch/EMAILS"       # email log dir
SMAILER="petey"                         # person(s) to email

# export the vars
export BATDIR BATNAM BATSVC BATPF SERVER SDIR SIN \
SPROC SLOG SMAIL SMAILER

pid=`ps -ef|grep "$BATPF" |grep -v grep |awk -F" " '{print $2}'`
 echo $pid

if [ "$pid" = "" ]
 then
   /usr/bin/sh $BATDIR/$BATNAM
   sleep 10
   mailx -s "${SERVER} ${BATNAM} restarted" petey
   sleep 10
   echo "$pid" > $SLOG/"$BATNAM-restart-on--`date +%F-%T`"
 else
   echo "service is ok"
   pid=""
fi


Last edited by olyanderson; 06-06-2013 at 04:57 PM.. Reason: got it, thanks. ill use from now one, im new here
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

unable to do mailx from shell script

Hi From within a shell script my mailx doesnt seem to work...can somebody tell me what is wrong... #!/bin/ksh #Script to verify wheather all databases listed are up and running #Script works with Oracle8 and above databases #Script has to be run by ./scriptname DBA=xiamin@unix.com echo... (3 Replies)
Discussion started by: xiamin
3 Replies

2. Linux

mailx: Unable to send Japanese

Hi All, I am facing problem in sending Japanese characters using mailx command in GNU linux machine. The mail is going with junk characters like "メールの-界へようこそ". I tried changing the LANG value to japan locale off UTF-8. But it doesn't worked. I have to send the data as body not as an... (0 Replies)
Discussion started by: Karteek
0 Replies

3. Solaris

Unable to send mail through mailx

Hi, I am using solaris 5.9 OS and I am facing an issues with mailx. My SMTP port is configured to listen 6190 and not the default one which is 25. I can send mail to my inbox when i do it manually through the following steps root@<dbname> # telnet 15.12.88.10 6190 Trying 15.12.88.10...... (0 Replies)
Discussion started by: Srinathkiru
0 Replies

4. HP-UX

[Solved] mailx : unknown user issue

Hi all, I know this issues has been discussed multiple times, i have gone through many such discussion but unfortunately i am still not able to solve the issue being faced. I have configured the sendmail.cf with the smtp host name (Editing the entry starting with DS...) Post that restarted... (7 Replies)
Discussion started by: chpsam
7 Replies

5. Shell Programming and Scripting

[Solved] Unable to call a python script from bash

Hi, I am trying to run a python script embedded in bash script. But is throwing me an error. Please help. Script: #!/bin/bash nohup /usr/bin/python /opt/web/http.py & Error: /usr/bin/python: can't open file '/opt/web/http.py': No such file or directory Please help me on this. (6 Replies)
Discussion started by: maddy26615
6 Replies

6. Red Hat

Can't stop/restart postfix - pid associated with another process

This issue could happen to any other service but in this case its commssioning Postfix - it seems i can't stop postfix as the PID relates to another service - i've delete the 'master.lock' but to no available - any ideas, memeory commands etc ? thanks in advance ps. the serve is in Production so... (2 Replies)
Discussion started by: stevie_velvet
2 Replies

7. Shell Programming and Scripting

Unable to get pid from fuser

bash-3.2$ fuser -f /bin/nohup.out /bin/nohup.out: 13136o 13111o The pid is 13136. Can you tell me how can i extract just the pid 13136 from the above output ? bash-3.2$ uname -a SunOS mymac 5.10 Generic_150400-26 sun4v sparc sun4v I was trying on this lines but i get strange... (3 Replies)
Discussion started by: mohtashims
3 Replies
COQ(1)							      General Commands Manual							    COQ(1)

NAME
coqtop - The Coq Proof Assistant toplevel system SYNOPSIS
coqtop [ options ] DESCRIPTION
coqtop is the toplevel system of Coq, for interactive use. It reads phrases on the standard input, and prints results on the standard out- put. For batch-oriented use of Coq, see coqc(1). OPTIONS
-h, --help Help. Will give you the complete list of options accepted by coqtop. -I dir, --include dir add directory dir in the include path -R dir coqdir recursively map physical dir to logical coqdir -top coqdir set the toplevel name to be coqdir instead of Top -inputstate filename, -is filename read state from file filename.coq -nois start with an empty initial state -outputstatefilename write state in file filename.coq -load-ml-object filename load ML object file filenname -load-ml-source filename load ML file filename -load-vernac-source filename, -l filename load Coq file filename.v (Load filename.) -load-vernac-source-verbose filename, -lv filename load verbosely Coq file filename.v (Load Verbose filename.) -load-vernac-object filename load Coq object file filename.vo -require filename load Coq object file filename.vo and import it (Require Import filename.) -compile filename compile Coq file filename.v (implies -batch ) -compile-verbose filename verbosely compile Coq file filename.v (implies -batch ) -opt run the native-code version of Coq -byte run the bytecode version of Coq -where print Coq's standard library location and exit -v print Coq version and exit -q skip loading of rcfile -init-file filename set the rcfile to filename -user uid use the rcfile of user uid -batch batch mode (exits just after arguments parsing) -boot boot mode (implies -q and -batch ) -emacs tells Coq it is executed under Emacs -dump-glob filename dump globalizations in file f (to be used by coqdoc(1) ) -with-geoproof (yes|no) to (de)activate special functions for Geoproof within Coqide (default is yes ) -impredicative-set set sort Set impredicative -dont-load-proofs don't load opaque proofs in memory -xml export XML files either to the hierarchy rooted in the directory $COQ_XML_LIBRARY_ROOT (if set) or to stdout (if unset) -quality improve the legibility of the proof terms produced by some tactics SEE ALSO
coqc(1), coq-tex(1), coqdep(1). The Coq Reference Manual. The Coq web site: http://coq.inria.fr October 11, 2006 COQ(1)
All times are GMT -4. The time now is 11:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy