Problem with script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Problem with script
# 1  
Old 06-22-2009
Problem with script

Hello All. I have a script that is suppossed to start up a daemon but when executed, simply hangs. Could you please take a look and let me know where the problem might be? TIA

Code:
###################################################################
#
# SCRIPT: dstart3000.sh
# Bring up the Domain
# AUTHOR: 
#
# Description:
# Start the Domain Daemon Server Process on Port 3000
# Execution Syntax:
# ./dstart3000.ksh
# Revision History:
#   2007_09_21  Script created
###################################################################
# Setting up variables
FATAL=255
SUCCESS=0
MAIL_SUBJECT="Domain Daemon Server Process failed to Start"
MAIL_TO="someone@somewhere.com"

program_name=`basename $0 .ksh`
start_time=`date +%y-%m-%d`
#Intializing log file and putting job start time
LOG_FILE="${GM_LOG}/${program_name}.${start_time}.log"
echo "Program ${program_name} started at ${start_time}" > ${LOG_FILE}
echo "Start DomainDaemon process at `date +%Y%m%d_%H%M%S`" >> ${LOG_FILE}
DomainDaemon -port 3000 -start > daemon3000.log 2> daemon3000.err
 if [ $? -ne 0 ]; then
    # The Domain Daemon Start failed ??
    echo ERROR - the Domain Daemon Start Server Failed >> ${LOG_FILE}
    mail -s "${MAIL_SUBJECT}" "${MAIL_TO}" < ${LOG_FILE}
    exit 1
   else
    echo Domain Daemon Started succesfully
 fi
echo  finish Domain Daemon Server Started Succesfully `date +%Y%m%d_%H%M%S` >> ${LOG_FILE}
# Save logfile
# Cleanup and close


Last edited by vgersh99; 06-22-2009 at 07:16 PM.. Reason: code tags, PLEASE!
# 2  
Old 06-22-2009
Is this the line?:

Code:
DomainDaemon -port 3000 -start > daemon3000.log 2> daemon3000.err

Try running it in the background...

Code:
DomainDaemon -port 3000 -start > daemon3000.log 2> daemon3000.err &

And if it dies when you close your session, run it nohup...

Code:
nohup DomainDaemon -port 3000 -start > daemon3000.log 2> daemon3000.err &

Hope this helps
# 3  
Old 06-22-2009
why don't you add 'set -x' to the script and see where it 'hangs'.
# 4  
Old 06-22-2009
hi, I have tried you script to run and from my point of view the script working fine.

I have changed only the header to #!/bin/bash then I've created a test.log with permission settings 755 and at last I've installed it on my debian OS mailutilities -- that's all!

see my mail

"/var/mail/####": 3 messages 2 unread
R 3 #### Di Jun 23 00:22 19/667 Domain Daemon Server Process failed to Start

§3

Subject: Domain Daemon Server Process failed to Start
To: <####@localhost>
From: #### <####@%%%%.@@@@@@@@@@@@@>
Date: Tue, 23 Jun 2009 00:22:28 +0200

Program test.sh started at 09-06-23
Start DomainDaemon process at 20090623_002228
ERROR - the Domain Daemon Start Server Failed
# 5  
Old 06-22-2009
That would have been useful info an hour ago Smilie

Can you define "hangs"?

What do the .err and .log files tell you (presuming more than the mail does)?
# 6  
Old 06-23-2009
Thanks! for the replies! I need to use Korn on this one so switching to bash is not an option. I am unfamiliar with '-x'. How do I implement this? As for 'hangs', I mean that the job runs but does not finish, i.e. return any messages or get a command prompt back. Also, no .err or .log files ever get created.

Last edited by grin1dan; 06-23-2009 at 02:34 PM.. Reason: Left out some info
# 7  
Old 06-24-2009
From the output of:

Code:
# help set
...
-x  Print commands and their arguments as they are executed.
...


so just put "set -x" at the top of the script before any other commands.

A much more ghetto and tedious way to do it is to add an "echo" command after every command.
Code:
command1
echo 1
command2
echo 2

so when your script "hangs" and all you see on the terminal is "1", then you know that you have a problem with "command2". It's much easier to go with set -x though, I was just trying to illustrate the principle.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem in calling a script inside a script

Hi team, I have a script in different folder. Now i want to call that script and execute that script from that path alone. My code is #!/bin/bash wname=yahoo PATH='/opt/IBM' wac=`/usr/bin/ls $PATH | /usr/bin/grep "$wname"` STOP=`/usr/bin/find $PATH/$wac -type f -name "stop.sh"`... (8 Replies)
Discussion started by: natraj005
8 Replies

2. Shell Programming and Scripting

Shell script newbie, what is problem with my script?

Hello, Ubuntu server 11.10 can anybody help what is problem with my shell script? #!/bin/bash #script to find out currently logged on user is root or not. if ] then echo "You are super" else echo "You are awesome!" fi When I run script, I get following output ./uid: line 3: I... (4 Replies)
Discussion started by: kaustubh
4 Replies

3. Shell Programming and Scripting

Problem while calling a script within a script

Hi , I have moduled my scripts in three scripts . From First script i am calling second and from second i am calling third for some check . Problem is with the third script call. ---In second script EXP ='test.\abc.\Server.*abc.xml.*' pid=$($HOME/bin/checkpid $EXP) --Third... (2 Replies)
Discussion started by: amrishn
2 Replies

4. Shell Programming and Scripting

Problem running a program/script in the background from a script

Hi all, I have a script that calls another program/script, xxx, to run in the background. Supposedly this program at most should finish within five (5) minutes so after five (5) minutes, I run some other steps to run the script into completion. My problem is sometimes the program takes... (5 Replies)
Discussion started by: newbie_01
5 Replies

5. Shell Programming and Scripting

Problem with a script

Hi everyone, I got a problem with a script. What it's supposed to do is: to take as arguments a directory name <dir> and a dimension (in byte) <dim>; if <dir> exists, to write name and dimension of every regular file within it that sizes lesser than <dim> in regFileList. Nothing happens... (10 Replies)
Discussion started by: Luke Bonham
10 Replies

6. Shell Programming and Scripting

script problem

Hello I am trying to execute the following script #!/bin/ksh ABC=/abc/def/ghi/jkl/mna/opq/input cd $ABC Filename=`ls -t $ABC | tail -1`; echo $Filename awk 'NR == 1 || substr($0,63,5) ~ /H... / && \ _++ == 1 { fn && close(fn); fn = "$Filename_" ++c; _ = 1 } { print > fn }' $Filename... (2 Replies)
Discussion started by: dsdev_123
2 Replies

7. Shell Programming and Scripting

call shell script from perl cgi script problem

hi,, i have perl scipt with line : system('./try.sh $t $d $m'); in shell scipt try.sh i have the line: echo $1 its not printing value of $t that i hav passed..y is it so..i am running it from apache web server (2 Replies)
Discussion started by: raksha.s
2 Replies

8. Shell Programming and Scripting

ssh script problem problem

Hi Please help me with the following problem with my script. The following block of code is not repeating in the while loop and exiting after searching for first message. input_file ========== host001-01 host001-02 2008-07-23 13:02:04,651 ConnectionFactory - Setting session state... (2 Replies)
Discussion started by: pcjandyala
2 Replies

9. Shell Programming and Scripting

Help. Script problem

hey guys. i have a bunch of programs in a script that needs to run as root and the rest as another user, we'll call him gabriel. now, in this script, i want to run the first few lines as root. now, how do i, after running as root, tell the script to run the remaining lines as the user gabriel?... (3 Replies)
Discussion started by: Terrible
3 Replies

10. UNIX for Dummies Questions & Answers

Problem starting a script from a 'main'-script

Please Help! :o I have a main script (ksh) where another script is called (convert_picture). Normally this works ok, but since some changes has been made on the unix-server (I dont know what :( ) suddenly it doesnt work anymore: i get an error message: ksh: convert_picture not found. I am... (3 Replies)
Discussion started by: Rakker
3 Replies
Login or Register to Ask a Question