Issue with script


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Issue with script
# 1  
Issue with script

Hi,

I am running below script using autosys.
Though the script is running fine, it fails the workflow but the autosys job shows success.
Can you please let me know where can i make change to script:-
Code:
#!/bin/ksh
#to test mail from directory
set -x
frequency=$1
param_file=/local/test
mail_dir=/local/test
if [ -f $param_file ]
then
rm $param_file
fi
touch $param_file
chmod 777 $param_file
echo "[Global]" > $param_file
echo '$$ENVIRONMENT'"=$ENVIRONMENT" >> $param_file
echo '$DBConnection_s'"=ITRAS" >> $param_file
echo '$$frequency'"=$1" >> $param_file
rm $mail_dir/*
$ITRC/scripts/itrc_startworkflow.ksh dummy wf_test
#mail_dir=/local/test
rm $mail_dir/alert_email_content1.out
#echo $mail_dir

find $mail_dir/* -type f | grep -q .
file_check=$?
if [ $file_check -ne 0 ]; then
  echo "Rows for alert  $1* doesnot exists"
 # echo "File $1* doesnot exists or No Files are older than $3 days in the directory $2" >> $log_file
  exit 0
fi

for file in $mail_dir/* ;
do
echo "$file"
/\n/g' "$file"
#mail_sub= echo $file | cut -d'/' -f8
mail_sub=`head -1 "$file"`
sed -i -e "1d" "$file"
mail_id=`head -1 "$file"`
sed -i -e "1d" "$file"
chmod 777 "$file"
echo "mail ID is  $mail_id"
echo "mail subject is " $mail_sub
cat $file | mailx -s "$mail_sub" "$mail_id"
#echo $mail_sub
done
exit 0

Moderator's Comments:
Mod Comment Please wrap all code, files, input & output/errors in CODE tags.
It makes them far easier to read and preserves spaces for indentation and fixed width data

Last edited by rbatte1; 06-17-2016 at 04:24 AM.. Reason: CODE tags
# 2  
Welcome rajrishi990,

Firstly, please wrap all code, files, input & output in [CODE] & [/CODE] tags. I have adjusted your post. It nor preserves your spacing which can make code much easier to read and is critical for fixed width data.

Thanks for the question.

How do you know that this is meant to error? If it displays the message made by Rows for alert $1* doesnot exists then the next thing you do is to exit 0 which is probably signalling success of the script back to the scheduler.

Try changing the exit code and see if it is that simple. Autosys may have a variety of return codes for various states, e.g. success, minor issue, warning, alert, error etc. or is may just have two - zero return code for success and any other number for a failure.

Have a play with that and see how you get on.


I hope that this helps,
Robin
# 3  
In your script no autosys is involved unless it is hidden in $ITRC/scripts/itrc_startworkflow.ksh. You don't examine this script's exit code - wouldn't that help?

I see you set the shell's -x option - why don't you show us the log of the run?
# 4  
Quote:
Code:
param_file=/local/test
mail_dir=/local/test

Something wrong here, a directory is not a file!
# 5  
In addition: if you run this script via some spooler you probably rely on an environment being there which isn't - similar to Cron Problem Number One. I can't see any part in your script that sets a proper environment. So chances are it isn't there.

I hope this helps.

bakunin
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #767
Difficulty: Medium
A victim cache is a cache used to hold blocks evicted from a CPU cache upon replacement.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Issue with pwd for script run by double click on script (MacOS High SIerra)

Hello, I have the following script that just archives and clears some log files. #!/bin/bash # script: archive_logs_and_clear # add date to logfile names and copy archive directory # clear logs # change to script directory cd ... (4 Replies)
Discussion started by: LMHmedchem
4 Replies

2. Shell Programming and Scripting

Issue in Script

I developed a script to group by 1st column and sum few of the column which are required, but while executing sum of 2nd column which has decimals in place is not getting correct sum. below is the script awk -F, '{a+=$2;b+=$33;c+=$58;d+=$11;e+=$50;}END{for(i in a)printf... (2 Replies)
Discussion started by: rramkrishnas
2 Replies

3. Shell Programming and Scripting

Issue with the script

I am trying to run a script which ftp the files from one server to another. Below is the script - #!/bin/bash echo "Please enter no : " read variable echo "You entered: $input_variable" host=xxxxx USER=xxx PASSWORD=xxx ftp -inv $HOST <<EOF user $USER $PASSWORD cd... (4 Replies)
Discussion started by: chandraprakash
4 Replies

4. Shell Programming and Scripting

Issue with script

Hi, I have a script which when i run in manually it runs properly, but when i run the same script using UC4 scheduler it dose not run properly. Below is the code i am using. i am not sure what is happening when i run this through UC4 the files are not generated. but when i run this manually it... (1 Reply)
Discussion started by: Mohammed_Tabish
1 Replies

5. Shell Programming and Scripting

Script issue

Hi Folks, I am going through a sample script which is not working. Also i want to understand the certain syntaxes #!/bin/sh clear x="y" echo "enter ur 1st no." read n1 echo "enter ur 2nd no." read n2 while do clear echo "1.sum" echo "2.subtraction" echo "3.product"... (3 Replies)
Discussion started by: rafa_fed2
3 Replies

6. Shell Programming and Scripting

What is issue with this script?

#!/bin/ksh i=1 while do j=0 while do echo "$i" j =`expr $j + 1` done i=`expr $i + 1` done (19 Replies)
Discussion started by: targetshell
19 Replies

7. Shell Programming and Scripting

Script Issue

#!/bin/bash ########################################### ADMIN="usera@mblonline.com" AMQ="userb@mblonline.com" SUBJECT="Remote Shutdown Client Status" MAIL="/bin/mail" ########################################### DAT=`date '+%d-%b-%Y'` PLUGIN="/usr/lib/nagios/plugins/check_nrpe" PORT="5666"... (2 Replies)
Discussion started by: telnor
2 Replies

8. Shell Programming and Scripting

Script running from another script issue

Hello All, I am ruuning the below script. userchecking.sh ########################### #! /bin/ksh NIS_SCRIPT_HOME="/mot/systems/NIS_SCRIPT_NEW" . $NIS_SCRIPT_HOME/common.env WORK_DIR="/mot/systems/scripts/" #WORK_DIR="/mot/b36376/myscripts/nis_user_automation"... (1 Reply)
Discussion started by: ajaincv
1 Replies

9. Shell Programming and Scripting

Issue with the script

#!/bin/ksh set -x SQLSTR="LOGIN/PASSWORD" sqlplus -s ${SQLSTR} @<<EOF set pagesize 0 feedback off verify off heading off echo off; UPDATE TABLE NAME SET VALUE = VALUE + 1 where VALUE2 = 'ABCDE'; exit; COMMIT; EOF i am not able to update the column and not able to exit from sqlplus. ... (7 Replies)
Discussion started by: karthicss
7 Replies

10. Shell Programming and Scripting

Bash script: issue changing directories in script

I am working on a script that checks two arguments at the command line. The first argument is a search pattern, the second can be a file or a directory, if it is a file a second script is called that checks it for the search pattern. If the second argument is a directory, it checks for the search... (5 Replies)
Discussion started by: Breakology
5 Replies

Featured Tech Videos