Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie needs scripting help

Status
Not open for further replies.

Jake99

IS-IT--Management
Jun 25, 2002
5
US
This is a great forum..wish I had found it earlier. :) Here is what I am looking to do. A file is created daily on my AIX server in this format - QLGYYYYMMDD. Based on what day it is I need to run a specific command on the file for the current day and output it to a file called RetLog. I will then be picking it up using FTP. If you need anymore specifics please let me know.


Thanks

Jake99
 
yeah, I need more specifics:

can you show us what you've tried so far?

thanks
 
I am not really sure where to start. I am a newbie at this and would like any input as to where I should begin.

Thanks
Jake99
 
Jake99,

Try this one, the first line must be the first
line in the script:

#!/bin/ksh
# Go to where my files are:

cd /target_dir/

# List all my files, pipe to my processing loop.

/bin/ls -1 |
while read file_nm ; do

echo Processing $file_nm

case $file_nm in

*.dat) echo "This one is a data file" ;;
*.idx) echo "This one is an index file"
echo Maybe I want to do some more commands...
date ; date ; cat /etc/motd ;
echo terminate the switch cases
echo with a double semi-colon,
echo like this:
;;
*) echo this will be the default fall-through ;;

esac # end the switch case.

echo =================================

done |
tee /tmp/error_log

# Redirect all of our processing output to a screen
# and a temp file of your choosing.

 
Here's your "starter for 10" :)
Code:
#!/bin/ksh

# set input file name based on current date
INFILE=QLG$(date +%Y%m%d)
echo Inputfile: $INFILE

# do stuff depending on which day it is
case $(date +%u) in
  1) echo "Do Sunday Stuff";;
  2) echo "Do Monday Stuff";;
  3) echo "Do Tuesday Stuff";;
  4) echo "Do Wednesday Stuff";;
  5) echo "Do Thursday Stuff";;
  6) echo "Do Friday Stuff";;
  7) echo "Do Saturday Stuff";;
esac
Greg.
 
Quickasarus,
Can you give some more explanation of your post. I am still sort of confused. Thanks for the help

Jake99
 
Ok I have finally figured this out and let me know if this would work to find files older then one day and copy them to a directory

find /fnsw/local/logs/qlogs/1 -name 'QLG*' -mtime +1 -exec cp {} ./retlog \;

How can I use this command to find files that are from the last 24 hours? Thanks for the help

Jake99
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top