Showing posts with label shell script. Show all posts
Showing posts with label shell script. Show all posts

Monday, February 24, 1997

m_trans: menu script to transfer files to PC

Author: Robert Lawson
Environment: Oracle database, HPUX
Description: This script is menu used by users to transfer files from unix system to PC's to work with spreadsheet.
Code Listing:
# File   : file_transfer_menu [m_trans]
# Purpose: file transfer host/pc
# Author : Robert Lawson 13-JAN-1997
# Mods : RobLaw 02/24/97 Remove file after successful transfer
#
# questions:
# - PC directory LOCAL_DIR="\\\users\\\$LOGNAME\\\data\\"
# without $LOGNAME and file name not tripping reserved escape sequences
# - notify if create date <> SYSDATE
# - generalize wher options are the same name as file?
# ls -l tt.sql
# -rw-r--r-- 1 roblaw users 937 Jan 10 11:19 tt.sql
# date
# Tue Jan 14 11:42:21 PST 1997
# ========================================================================
function do_transfer
{
if [ $LOCAL_FILE != "{}" ]
then
echo "Local PC file name ($LOCAL_FILE): \c"
read line
if [ "$line" ]
then
echo "line = *$line*"
LOCAL_FILE="$line"
fi
fi

if [ $HOST_FILE != "{}" ]
then
if [ -r $HOST_FILE ]
then
ls -l $HOST_FILE
echo "Enter \c"
read line
else
echo "HOST_FILE $HOST_FILE does not exist"
echo "Enter \c"
read line
return 1
fi
fi

X_COMMAND="receive $LOCAL_FILE from $HOST_FILE del"

# from korninit from WRQ Web Site, by John Imhoff
echo "\033&oC$X_COMMAND\r"
read hoststseq
if [ "$hoststseq" != F ]
then
$hoststseq
read status
if [ "$status" = S ]
then
/bin/rm -f $HOST_FILE
echo "Successful file transfer. Enter "
read line
else
echo "X_COMMAND: $X_COMMAND"
echo "ERROR 100: Status=$status. File transfer failed at startup. Enter "
read line
fi
else
echo "X_COMMAND: $X_COMMAND"
echo "ERROR 101: Status=$hostseq. File transfer failed initiating host sequence. Enter "
read line
fi
}
# ========================================================================
echo " ** File Transfer Menu **"
echo
echo " Options:"
echo " 1. Backlog (oeorf.lst)"
echo " 2. Backlog (oeorf.lst to diskette, Kessler)"
echo " 3. Work order routing (wo100.txt)"
echo " 4. Schedule demand (pn103.txt)"
echo " 5. Transactions (ic101.txt)"
echo " 6. Booked orders (pn105.txt)"
echo " 7. Shipped orders (pn106.txt)"
echo " 8. MFG Item Summary (ic104.txt)"
echo " 9. Model Item Summary (pn107.txt)"
echo " 10. MFG Item Summary (ic105.txt)"
echo " 11. Production Rate Detail (ic106.txt)"
echo " 12. Fabrication WO Status-powo (pn111.txt)"
echo " G General transfer"
echo " H Help"
echo " E Exit"
echo " Enter option $LOGNAME: \c"
read option; typeset -u option

case $option in
1) # backlog
HOST_FILE="oeorf.lst"
LOCAL_FILE="oeorf.lst"
do_transfer
;;
2) # backlog, to diskette
HOST_FILE="oeorf.lst"
LOCAL_FILE="a:\oeorf.lst"
do_transfer
;;
3) # WO routing
HOST_FILE="wo100.txt"
LOCAL_FILE="123\wo100.txt"
do_transfer
;;
4) # Schedule demand
HOST_FILE="pn103.txt"
LOCAL_FILE="123\pn103.txt"
do_transfer
;;
5) # Transactions
HOST_FILE="ic101.txt"
LOCAL_FILE="123\ic101.txt"
do_transfer
;;
6) # Booked Orders
HOST_FILE="pn105.txt"
LOCAL_FILE="123\pn105.txt"
do_transfer
;;
7) # Shipped orders
HOST_FILE="pn106.txt"
LOCAL_FILE="123\pn106.txt"
do_transfer
;;
8) # MFG Item Summary
HOST_FILE="ic104.txt"
LOCAL_FILE="123\ic104.txt"
do_transfer
;;
9) # Model Item Summary
HOST_FILE="pn107.txt"
LOCAL_FILE="123\pn107.txt"
do_transfer
;;
10) # MFG Item Summary
HOST_FILE="ic105.txt"
LOCAL_FILE="123\ic105.txt"
do_transfer
;;
11) # Production Rate Detail
HOST_FILE="ic106.txt"
LOCAL_FILE="123\ic106.txt"
do_transfer
;;
12) # Fabrication WO status
HOST_FILE="pn111.txt"
LOCAL_FILE="123\pn111.txt"
do_transfer
;;
G) # General transfer
HOST_FILE="{}"
LOCAL_FILE="{}"
do_transfer
;;
H) # Help
echo
echo "file_transfer_menu: Help"
echo "This menu will tranfer data file created on host system for use on pc."
echo "If you have 123 file, then go to 123 and either type file name, or use"
echo ".txt extension."
echo "Most common problems you'll encounter are:"
echo "1. JIT program not run, and thus no host file."
echo "2. JIT program not run, and thus one old host file."
echo "3. Your default PC directory is NOT \\\user\\\name\\\data."
echo "4. You used qualified PC directory name for local file (bug today)."
echo "5. You are having a bad hair day."
echo "Enter \c"
read line
;;
EEXITX)
echo "See ya later $LOGNAME"
;;
*) # bad apple
echo "opiton $option"
;;
esac

Wednesday, September 11, 1996

p_adv: ping advice on equipment status

Author: Robert Lawson
Environment: Oracle database, HPUX
Description: This script polls key devices on network and emails when they can not be reached.
Code Listing:

# File: ping_advise [p_adv]
# Purpose: ping device and advise of failures
# Author/Date: Robert Lawson 09-NOV-1996
#
# Technique: ping IP address, write results to file, see if null (failed)
# Notes: this script will fail on not detecting an IP address, so you
# to restart you must?????
#
PROG_NAME=ping_advise # name of script
MAIL_USER=roblaw # whom to send email to
SLEEP_LIMIT=60 # pause number of seconds

# do ping, parameters are:
# 1 passed IP address to ping
# 2 passed common name for IP address
# 3 passed name to send mail to
# ? returned 0=OK, 1=failed
function ping_em
{
echo "Processing IP_ADDRESS = $1 for $2"
rm $PROG_NAME.tmp
/etc/ping $1 64 1grep '1 packets re'>$PROG_NAME.tmp
if [ -s $PROG_NAME.tmp ]
then
echo "passed"
return 0
else
echo "failed"
cat > $PROG_NAME.tmp
mail $3 <$PROG_NAME.tmp return 1 fi } # main loop while true do ping_em "192.1.1.254" "CA ROUTER" "$MAIL_USER" if [ $? -eq 1 ] then break fi ping_em "192.1.2.254" "FL ROUTER" "$MAIL_USER" if [ $? -eq 1 ] then break fi ping_em "192.1.2.253" "JUNK" "$MAIL_USER" if [ $? -eq 1 ] then break fi sleep $SLEEP_LIMIT done

Friday, August 16, 1996

w_sql: weekly production job schedule script

Author: Robert Lawson
Environment: Oracle database, HPUX
Description: This script is scheduled weekly jobs via CRON.
Code Listing
:
# file name: /home/common/bin/weekly_sql
# purpose: execute weekly sql programs
# whom : robert lawson 08/16/96

# oracle environment variables
ORACLE_HOME=/u01/home/oracle/product/7.1.4
ORACLE_SID=JIT
export ORACLE_HOME ORACLE_SID

# 08/16/94 roblaw: archive JIT bill_of_material_log
/u01/home/oracle/product/7.1.4/bin/sqlplus jit/erp @/home/common/sql/upd_x_bill_of_material_log

# 08/16/94 roblaw: archive JIT item_trans_log
# /u01/home/oracle/product/7.1.4/bin/sqlplus jit/erp @/home/common/sql/upd_x_item_trans_log

# 08/16/94 roblaw: archive JIT lot_trace
/u01/home/oracle/product/7.1.4/bin/sqlplus jit/erp @/home/common/sql/upd_x_lot_trace

# 08/16/94 roblaw: archive JIT shipping_loc
/u01/home/oracle/product/7.1.4/bin/sqlplus jit/erp @/home/common/sql/upd_x_shipping_loc

# 06/30/97 roblaw: temp for SO reconfigure
/u01/home/oracle/product/7.1.4/bin/sqlplus jit/erp @/home/common/sql/oecu
lp -dca_corp1 /home/common/oracle/oecu.lst