I want to run the script with different criteria if text file has wc
Or do not match!
My script:
#! / Bin / sh x = echo `wc -l '/scc/ftp/mrdr_rpt/yet_to_load.txt" `if [$ X -gt 0] then sh /scc/ftp/mrdr_rpt/eam.ksh/scc/ftp/mrdr_rpt the /vinu_mrdr_rpt.txt/scc/ftp/mrdr_rpt/yet_to_load.txt @ from.com to.name@to the Com Elif Sh /scc/ftp/mrdr_rpt/eamkksh/scc/ftp/mrdr_rpt/vinu_mrdr_rptktxt for / Scc / ftp / mrdr_rpt / yet_to_load.txt from @ from.com to.name@to.com, hi.name @ hicode fi
You are required to get the wc
correct, and avoid getting the file name in your output you have:
x = echo `wc -l '/scc/ftp/mrdr_rpt/yet_to_load.txt" `if [$ x -gt 0]
echo
does not want you to wc < / Code> should use the input redirection (
wc
is a bit weird.) If you give the name of a file to process it, then the output contains the name of the file; This is the standard input process, does not include the file name in the output.) You should use the $ (...)
preference for back-quotes.
x = $ (wc -l & lt; "/ scc / ftp / if [$ x -gt 0]
if you want to check it If the file is not empty (instead of having a file with the data, but not a new line), then you can use more direct testing:
if [-s "/ scc /ftp/mrdr_rpt/yet_to_load.txt "]
you may
DIR =" / scc / ftp / mrdr_rpt "
and then referring to it to reduce ugly iterations in your code like using a name:
If [$ x -gt 0] then sh "$ DIR / eam.ksh" "$ DIR / vinu_mrdr_rpt.txt" "$ DIR / yet_to_load.txt" \ from@from.com To.name@to.com else sh "$ DIR / Eam.ksh "" $ DIR / vinu_mrdr_rpt.txt "" $ DIR / yet_to_load.txt "@from @ fro M.com to.name@to.com, hi.name@hi.com fi
However, I think the second line does not require a comma, and it can be better to use:
which = "from@from.com to .name @ to.com "if [-s" $ DIR / yet_to_load.txt "] who =" $ who hi Name@hi.com "fi sh" $ DIR / eam.ksh "" $ DIR / vinu_mrdr_rpt.txt "" $ DIR / yet_to_load.txt "$ which
then you can only enter one line with all the names in it. And you can do even better with an array instead of the string:
which = ("from@from.com" "to.name@to.com") if [-s "$ DIR /yet_to_load.txt"] then who = = ("$ that hi.name@hi.com" "first name last name
No comments:
Post a Comment