Link to home
Start Free TrialLog in
Avatar of Wobbs_pei
Wobbs_pei

asked on

shell unix programming

I am not a unix anything but need to figure out what this script does.
Does this  script create a file ( file name ) what the contents of the file would be and also where this script places the file and also if each file overwrites a previous one.
I would love for someone to step me through each line.

#
if [ $# -ne 2 ] ; then
        echo Usage: $0 'first|second|third|last' code
        exit 1
fi
#
#
case $1 in
        first | FIRST )
                PHONE="9,16053398788"
                ;;
        second | SECOND )
                PHONE="9,16054927763"
                ;;
        third | THIRD )
                PHONE="9,16058657899"
                ;;
        last | LAST )
                PHONE="9,16053339843"
                ;;
        * )
                echo Unknown number.
                exit 2
                ;;
esac
#
#
#
tempfile=$$.page
cd /usr/tmp
echo $PHONE  $2 > $tempfile
sftp dev@omaha09 <<!
cd /usr/local/tocage
put $tempfile
quit
!
/usr/bin/rm $tempfile
ASKER CERTIFIED SOLUTION
Avatar of xterm
xterm

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of farzanj
This code expects two command line parameters, one of first, second, third or last and the filename.

#
if [ $# -ne 2 ] ; then
        echo Usage: $0 'first|second|third|last' code
        exit 1
fi
#
Avatar of xterm
xterm

The file that would be uploaded to the remote server would have one line in it that would look something like this:

9,16053398788 xxx

(where "xxx" is the code, or the 2nd argument to the script.  The author however does not put any validation in the script to make sure the code field is accurate)
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This has nothing to do with PowerShell, why is this in the PowerShell zone?
Avatar of Wobbs_pei

ASKER

Thank you both