Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

issue with running .sh file

Hi,

 

I have a job that runs .sh file but talend shows the complete status though the job still runs. Any idea how to control this so that talend gives the complete status only after .sh execution or all the command completes on .sh file. 

Labels (2)
8 Replies
Anonymous
Not applicable
Author

Hello,

Are your job running well when you execute .sh file? What does the complete status look like? Could you please give us some trouble screenshots?

Best regards

Sabrina

Anonymous
Not applicable
Author

Hi, 

 

I am using tssh component where it calls .sh file from unix. After i run this job in talend. I see connected, completed and disconnected message on talend console and then I go check on the log that sh file generates, i see these files generated even though status on the talend shows completed. 

 

Below is part of the shell script. This script basically generates log files and has operations like creating tables, inserting data to table and so on. And all these operations complete successfully after talend complete message. I want talend to show me complete after finishing all these operations. 

 

./file.properties

targettable="Account"
echo "Start execution of ${targettable} table execution ${scripts_dir}"
echo "logged at ${log_dir}"
echo "File Datetime: ${FILE_DATETIME}"
echo "queue name: ${queue_name}"
echo "............"
echo "${scripts_dir}${targettable}_TXT_to_HIST.hql"
echo "............"

# creating log files for hive file processing
log_file_name=${log_dir}${targettable}data_load_${FILE_DATETIME}.log

touch $log_file_name
exec >> $log_file_name;
exec 2>> $log_file_name;

echo "successfully created logfile...."
echo $log_file_name

echo "Script executed by `whoami` at `date "+%Y-%m-%d %H:%M:%S"`"
echo "Project directory: $dir_project"

job_message="Populable ${targettable} table"
user=`whoami`
incrementaltable=${targettable}_stg
job_id=1

...contd

Anonymous
Not applicable
Author

Any update to this please. If any questions please let me know. 

Anonymous
Not applicable
Author

hello,
Right click on your .sh file and select Properties:

In the Permissions tab, check Allow executing file as program:

Close the Properties window and double-click the file. A dialog will pop up giving you the option to run the script in a terminal:
regards
jenifer
Anonymous
Not applicable
Author

Hi, this sh file is in unix machine. And I am connecting to execute from Talend. 

Anonymous
Not applicable
Author

Hello,

 

 

Add wait in shell script

 

Thanks

Anonymous
Not applicable
Author

Hello,

 

Suppose cmd is having your script(.sh) then assuming it takes time more than 30 sec (time taking task) then
refer below Script.
Hope it helps!!

 

cmd="run.sh"
status="Running"
while [ "$status" != "Completed"]
do
result=`ps aux | grep -i "$cmd" | grep -v "grep" | wc -l`
if [ $result -lt 1 ]
then
echo "script $cmd completed sucessfully ! "
status="Completed"
fi
done
echo "Completed the Task"

 

--
Don't forget to give kudos when a reply is helpful

 

Thanks,

pmusk1601547000
Contributor
Contributor

Give execute permission to your script:

chmod +x /path/to/yourscript.sh

And to run your script:

/path/to/yourscript.sh

Since 

.

 

 refers to the current directory: if 

yourscript.sh

 is in the current directory, you can simplify this to:

./yourscript.sh

https://jiofilocalhtml.run https://forpc.onl