• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

unix shell script

 
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I want to write a shell script program call "ccompute" and use that program to invoke other SAS program.
I need to take in 3 parameter

ccompute Version1 USA 20040630 20040731

if the format is not valid
echo

Format should be :

ccompute [Version] [Country] [start date] [end date]

and I will store this 4 parameters into variable.

Can anyone help me?
Thanks a lot!

Jack
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't have much experience with shell scripting, but I happened to have this handy link to an on-line book on Linux and Bash.
 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, I'm going to assume you may want something like a c-shell:

#!/usr/bin/csh

if ($#argv < 4) then
echo " "
echo "You must enter these four arguments:"
echo " "
echo " version"
echo " country"
echo " start date (MMDDYYYY)"
echo " end date (MMDDYYYY)"
echo " "
exit
else
$SASHOME -autoexec $HOME/autoexec.sas -sysparm "$1-$2-$3-$4" sasjob.sas \&
endif


Does that help?

Pat
 
Jackie Wang
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a #!/bin/csh -f
shell script which already taken in the parameters which user input
and a driver list with the country
country.txt
USA
HKG
KOR

set version = $1
set country = $2
set start = $3
set end = $4

example: versionA, USA, 20030723, 20040724

I want to have some error checking:
1) Check whether $3 $4 is a valid date
2) Check whether $2 is in the country.txt
3) output location:
echo start location: /place/200307
echo start location: /place/200407
I don't know how to use substr function here and keep giving me syntax error
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

generates a file with that timestamp.
Then extracts the generated date, and compares it to the parameter.
This is neccessary, because 'touch 20031232' corrects the date to '20040101'.


Exitcode 0 indicates success, else: failure.
You can test it with:
sh inlist.sh foo && echo "yes"
 
Jackie Wang
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks stefan
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic