r_kar
asked on
Could you please explain the unix shell code
Hi all,
Please explain the code in detail. I have 2 sample scripts, but I didn't get clear idea about this. I am new to this shell scripting area.
1.
#!/bin/ksh
PATH=$PATH:/usr/local/bin: /users/pgp -6.5.2
WORKDIR=/users/xfercrd
export PATH WORKDIR
find $WORKDIR/archive -mtime +45 -exec rm {} \;
cp $WORKDIR/cuc.ftp $WORKDIR/cuc.ftp.save
cp $WORKDIR/ftpupload $WORKDIR/ftpupload.save
cp $WORKDIR/vaxdir $WORKDIR/vaxdir.save
$WORKDIR/bin/getdirlist
$WORKDIR/getdir > $WORKDIR/vaxdir
$WORKDIR/bin/makeqfile
$WORKDIR/cuc.ftp
PGPPASS="hardware rocket cafe"
PGPPATH=/users/cucpgp
export PGPPASS PGPPATH
$WORKDIR/bin/procftp
PGPPASS=""
export PGPPASS
cp $WORKDIR/?CUE* $WORKDIR/archive
rm $WORKDIR/S*
and 2 program is
#!/bin/ksh
# File : lbl
# Set Variables
PATH=$PATH:/usr/local/bin
WORKDIR=/users/xferexplbl
export PATH WORKDIR
dirpath='$leg'
export dirpath
# Remove Archive Files Older Than 60 Days
find $WORKDIR/archive -mtime +60 -exec rm {} \;
# Copy Old FTP Runs To A Backup
cp $WORKDIR/cuc.ftp $WORKDIR/cuc.ftp.save
cp $WORKDIR/vaxdir $WORKDIR/vaxdir.save
# FTP To Retrieve A List Of File Names To Be Picked Up
ftp -v corp.cuc.com << EOFDIR | tee $WORKDIR/vaxdir
cd exprpt
dir EXPSCRLBL*
quit
EOFDIR
# Create FTP Command File
$WORKDIR/bin/mkftpfile
# Execute FTP Command File
$WORKDIR/cuc.ftp
# Create Upload File, FTP Upload Command File
# And Email And Log Files
$WORKDIR/bin/mkrecord.pl
# Execute FTP Upload Command File (Copy To Production)
$WORKDIR/ftpupload
# Compress Files And Move To Archive Directory
compress $WORKDIR/EXP*
mv $WORKDIR/EXP* $WORKDIR/archive
---------------------
Why $PATH is specified in the below statement?
# Set Variables
PATH=$PATH:/usr/local/bin
Thanks
r_kar
Please explain the code in detail. I have 2 sample scripts, but I didn't get clear idea about this. I am new to this shell scripting area.
1.
#!/bin/ksh
PATH=$PATH:/usr/local/bin:
WORKDIR=/users/xfercrd
export PATH WORKDIR
find $WORKDIR/archive -mtime +45 -exec rm {} \;
cp $WORKDIR/cuc.ftp $WORKDIR/cuc.ftp.save
cp $WORKDIR/ftpupload $WORKDIR/ftpupload.save
cp $WORKDIR/vaxdir $WORKDIR/vaxdir.save
$WORKDIR/bin/getdirlist
$WORKDIR/getdir > $WORKDIR/vaxdir
$WORKDIR/bin/makeqfile
$WORKDIR/cuc.ftp
PGPPASS="hardware rocket cafe"
PGPPATH=/users/cucpgp
export PGPPASS PGPPATH
$WORKDIR/bin/procftp
PGPPASS=""
export PGPPASS
cp $WORKDIR/?CUE* $WORKDIR/archive
rm $WORKDIR/S*
and 2 program is
#!/bin/ksh
# File : lbl
# Set Variables
PATH=$PATH:/usr/local/bin
WORKDIR=/users/xferexplbl
export PATH WORKDIR
dirpath='$leg'
export dirpath
# Remove Archive Files Older Than 60 Days
find $WORKDIR/archive -mtime +60 -exec rm {} \;
# Copy Old FTP Runs To A Backup
cp $WORKDIR/cuc.ftp $WORKDIR/cuc.ftp.save
cp $WORKDIR/vaxdir $WORKDIR/vaxdir.save
# FTP To Retrieve A List Of File Names To Be Picked Up
ftp -v corp.cuc.com << EOFDIR | tee $WORKDIR/vaxdir
cd exprpt
dir EXPSCRLBL*
quit
EOFDIR
# Create FTP Command File
$WORKDIR/bin/mkftpfile
# Execute FTP Command File
$WORKDIR/cuc.ftp
# Create Upload File, FTP Upload Command File
# And Email And Log Files
$WORKDIR/bin/mkrecord.pl
# Execute FTP Upload Command File (Copy To Production)
$WORKDIR/ftpupload
# Compress Files And Move To Archive Directory
compress $WORKDIR/EXP*
mv $WORKDIR/EXP* $WORKDIR/archive
---------------------
Why $PATH is specified in the below statement?
# Set Variables
PATH=$PATH:/usr/local/bin
Thanks
r_kar
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
> Please explain the code in detail
anything of the form:
VARIABLE=VALUE
in your script sets a variable named VARIABLE to the value VALUE
the usage of $VARIABLE evaluates to the variables value (VALUE in my example)
export in your script makes the variable available to aother called programs
anything else are UNIX programs being called
anything of the form:
VARIABLE=VALUE
in your script sets a variable named VARIABLE to the value VALUE
the usage of $VARIABLE evaluates to the variables value (VALUE in my example)
export in your script makes the variable available to aother called programs
anything else are UNIX programs being called
ASKER
Hi yuzh,
Thank you for your valuable information.
Regards,
r_kar
Thank you for your valuable information.
Regards,
r_kar
ASKER
Hi yuzh,
Could you please explain this statement? It copies what type of files to archive directory?
cp $WORKDIR/?CUE* $WORKDIR/archive
and what the above statement does?
cp $WORKDIR/?CU??.??? $WORKDIR/archive
I am going to award you the points. Please answer to this
Thanks
Could you please explain this statement? It copies what type of files to archive directory?
cp $WORKDIR/?CUE* $WORKDIR/archive
and what the above statement does?
cp $WORKDIR/?CU??.??? $WORKDIR/archive
I am going to award you the points. Please answer to this
Thanks
? and * are wildcard characters. The wildcard ? matches any one character. The wildcard * matches any grouping of zero or more characters.
?CU??.??? mactch filename start with ANY char following by CU following by 2 chars and a
DOT . and three chars, eg:
mach
1CUab.abc
SCUmm.xyz, etc
cp $WORKDIR/?CU??.??? $WORKDIR/archive
will copy the files to dir $WORKDIR/archive, in your case
from: /users/xfercrd to /users/xfercrd/archive
Please have a look at the following page to learn more about WILDCARD chars:
http://www.sfu.ca/acs/howtos/b/b-8.htm
?CU??.??? mactch filename start with ANY char following by CU following by 2 chars and a
DOT . and three chars, eg:
mach
1CUab.abc
SCUmm.xyz, etc
cp $WORKDIR/?CU??.??? $WORKDIR/archive
will copy the files to dir $WORKDIR/archive, in your case
from: /users/xfercrd to /users/xfercrd/archive
Please have a look at the following page to learn more about WILDCARD chars:
http://www.sfu.ca/acs/howtos/b/b-8.htm
ASKER
Hi yuzh,
Thanks for your quick reply and excellent work.
Regards,
r_kar
Thanks for your quick reply and excellent work.
Regards,
r_kar
> # Set Variables
> PATH=$PATH:/usr/local/bin
This has the effect of appending /usr/local/bin to the existing PATH.