Using Shell Scripts as Concurrent Programs in EBS
Recently, I started looking at way to address a scheduling problem when moving files associated with our business partners. We currently have a three step process:
- Schedule a Concurrent Program to produce a file
- Set up a cronjob to schedule a shell script to move and archive that file on a SAMBA server for our Business Units to access (we are a Windows shop)
- Using Windows Scheduler, launch a C# program that will move the file from the SAMBA server to an FTP site where the business partner can “pick up” the file.
#!/bin/ksh
# File name: ftp_setup.sh
# Description: Define values for remote ftp server
################################ REMOTE FTP ###########################
export blog_host=’ftp01.blog.com’
export blog_user=’blog12345′
export blog_pwd=’DE45rtY7′
export blog_ftp_target=’upload’
export blog_file=’filename’
export blog_email=’addy1@emailaddy.com
########################################################################FILE #2
#!/bin/sh
# File name: ftp_interface.sh (extension changed to prog for EBS concurrent program)
# Description: Define values for remote ftp server
################################ EXECUTION SCRIPT######################
. /home/dbryant/Documents/ftp_setup.sh
echo “loading values”
if [ $5== “Yes” ]; then #parameter passed in from Concurrent Program
/home/dbryant/Documents/do_ftp.sh $blog_host $blog_user $blog_pwd $blog_ftp_target $blog_file $blog_email
elif [ $5 == “No” ]; then
echo “No FTP!”
else
echo “Invalid option please enter (Yes or No)”
fi
echo “End”
FILE #3
#!/bin/ksh
#—————————————————
# Script Name: DO_FTP.prog
# Script Purpose: FTP file to business
# Script Dependencies: file exists
#—————————————————
#FTP script
ftp -n $1 <<end_script end_script=”” i=””>
quote USER $2
quote PASS $3
cd $4
put $5
quit
END_SCRIPT
echo “The file transfer was successful” | mailx -s “FTP File Transfer Notification” $6
exit 0
Once I have my scripts written and tested, I need to put them in the $XBOL_TOP/bin directory. While only the one file you are going to execute as part of the request set needs to be in this directory, it just makes it easier.
1. You will need to change the file extension of the script you are registering to .prog. In this case FILE #2: ftp_interface.sh will be ftp_interface.prog.
2. Next, change the permissions on the file to 755.
3. Create a symbolic link to the script.
You can now register this as a Concurrent Program and/or include it in a Request Set. There are plenty of blog post and documentation for that, so have at it.
Something to note: If you decide to pass a parameter to you shell script, you will need to start with $5. The first four are reserved for the USERID, REQUEST,_ID, RESP_ID, RESP_APPL_ID.
Have Fun!!