The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
LANG=C not English? dotancohen Linux 4 03-11-2008 12:40 AM
auto decode a value to different value nhatch Shell Programming and Scripting 2 05-16-2007 09:01 AM
Decode email mskarica Shell Programming and Scripting 6 03-17-2005 09:31 PM
gunzip and base64 decode a string handak9 High Level Programming 2 10-23-2004 06:05 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-16-2002
Registered User
 

Join Date: Aug 2001
Location: Toronto
Posts: 29
Please decode in English

Hello: Can anyone please decode this script in English. I have also made some comments which I know.. The actual script does not have one comment also..

#! /bin/ksh

. odbmsprd_env.ksh #setting the env..

echo $0 Started at : `date '+%d-%m-%Y %H:%M:%S'`
# what's echo $0

curdt=`date '+%Y%m%d%H%M%S'`

file=rpt
# why file=rpt

#what's $# ==3 -- I know we pass 3 parameters to the script and 3rd param is file name and 1st is startdate and 2nd is enddate.

if (( $# == 3 ))
then
echo arguments: $1 $2 $3
sql @rcvdata_p.sql $1 $2
file=$3
fi

# We are calling sql scripts to do some processing.
sql @rcvstmt3_p.sql
sql @rcvrep_p.sql

# We are checking number of lines in the file pur_jur.csv
lns=`cat pur_jur.csv|wc -l`

# If we have lines in the file, then do processing
if (( $lns > 0 ))
then
echo $lns records found in PURCHASE JOURNAL
# Debug into english the next line
sed 's/ //g' pur_jur.csv|sed 's/,//g'|sed 's/|/,/g' > pur_jur1.csv
# I understand the rest of the program
mv pur_jur1.csv pur_jur_"$file".csv
ftp_to_q_pnet.ksh pur_jur_"$file".csv
compress pur_jur_"$file".csv
mv /home/odbms/prod/cg_batch/purchase_journal/pur_jur_"$file".csv.Z /dataload/odbms/dataout/pur_jur_"$file".$curdt.csv.Z
else
echo No records found for Purchase Journal
rm pur_jur.csv
fi

echo $0 ended at : `date '+%d-%m-%Y %H:%M:%S'`
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 07-16-2002
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,355
echo $0 will display the script's name


if (( $# == 3 ))

this asks "is the number of arguments = 3?"?


sed 's/ //g' pur_jur.csv|sed 's/,//g'|sed 's/|/,/g' > pur_jur1.csv

Take the file called pur_jur.ssv and make some changes:
1. Remove all spaces
2. Remove all commas
3. Change any | to a comma
Call the resulting file jur_jur1.csv
Reply With Quote
  #3 (permalink)  
Old 07-16-2002
Registered User
 

Join Date: Aug 2001
Location: Toronto
Posts: 29
Thanks Perderabo for your response..

Just Two more Qns..

What is $0 ??
I know $1 is 1st parameter and so on..

Why is variable "file"=rpt ??

Please explain..

Thanks, ST2000
Reply With Quote
  #4 (permalink)  
Old 07-16-2002
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,355
$0 is the name of the script. Suppose I type a command like this:

somescript option filename

You seem to know that $1 will be "option" and $2 will be "filename". You need to accept that $0 will be "somescript" as well.

As for:
file=rpt

This creates a variable named file and sets it equal to "rpt". You can see references to $file in a line like:
mv pur_jur1.csv pur_jur_"$file".csv

That will become
mv pur_jur1.csv pur_jur_rpt.csv
Reply With Quote
  #5 (permalink)  
Old 07-16-2002
Registered User
 

Join Date: Aug 2001
Location: Toronto
Posts: 29
Great man.. Thx a lot again

ST2000
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:33 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0