If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > simple shell scripting help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-27-11, 13:04
beerpong beerpong is offline
Registered User
 
Join Date: Jul 2011
Posts: 3
simple shell scripting help

i need help with this i got the first part down..

Required Errorlevels

Errorlevel # Event Information

0 Script functions correctly
10 No arguments provided on command line (=0)
12 First argument present, but not what expected (“-i”)
13 Second argument missing on command line
14 Second argument present, but file does not exist
15 Third argument missing on command line
16 Third argument present, but not what expected (“-o”)
17 Fourth argument missing on command line
18 Too many arguments provided on command line (>4)

i have this this should be right now i need to now how to do the screen shots i linked at the bottom..


if [ $# -eq 0 ]
then
echo no arguments proviede on command line
exit 10
fi


if [ "$1" != "-i" ]
then
echo First argument present, but not what expected (“-i”)
exit 12
fi


if [ "$2" = "" ]
then
echo Second argument missing on command line
exit 13
fi


if [ ! -e $2 ]
then
echo Second argument present, but file does not exist
exit 14
fi


if [ "$3" = "" ]
then
echo Third argument missing on command line
exit 15
fi

if [ "$3" != "-o" ]
then
echo Third argument present, but not what expected (“-o”)
exit 16
fi

if [ "$4" = "" ]
then
echo Fourth argument missing on command line
exit 17
fi

if [ $# -gt 4 ]
then
echo Too many arguments provided on command line (>4)
exit 18
fi

2 part...here is the screen shot hope you can help me!!
ImageShack® - Online Photo and Video Hosting <<<--------attached photo for the 2nd part

i dont understand

Last edited by beerpong; 07-27-11 at 13:10.
Reply With Quote
  #2 (permalink)  
Old 07-27-11, 15:51
kitaman kitaman is offline
Papabi's friend
 
Join Date: Sep 2009
Location: Ontario
Posts: 629
Part two (I assume) just requires you to display "echo" the arguments.
Code:
echo This is argument 1  $1
Check the man page for echo to see if you need quotes, and a "-e" option.
Consider the difference between using "echo" and "printf".

Try the following at the $ prompt
$a=abc
$echo $a
$echo -e "$a \n"
$echo -e "$a \c"

Last edited by kitaman; 07-27-11 at 15:55.
Reply With Quote
  #3 (permalink)  
Old 07-27-11, 16:17
beerpong beerpong is offline
Registered User
 
Join Date: Jul 2011
Posts: 3
how would i start it off tho...

where do i start puting in that stuff?

i dont no where to even start number to? like do i start under all the scripts or do i add to number 4?

i dont no..
Reply With Quote
  #4 (permalink)  
Old 07-27-11, 18:28
kitaman kitaman is offline
Papabi's friend
 
Join Date: Sep 2009
Location: Ontario
Posts: 629
Code:
#you should start the script with one of the following 3 lines

#!/bin/ksh
#!/bin/ksh
#!/bin/bash


if [ $# -eq 0 ]
then
echo no arguments proviede on command line
exit 10
fi


if [ "$1" != "-i" ]
then
echo First argument present, but not what expected (“-i”)
exit 12
fi


if [ "$2" = "" ]
then
echo Second argument missing on command line
exit 13
fi


if [ ! -e $2 ]
then
echo Second argument present, but file does not exist
exit 14
fi


if [ "$3" = "" ]
then
echo Third argument missing on command line
exit 15
fi

if [ "$3" != "-o" ]
then
echo Third argument present, but not what expected (“-o”)
exit 16
fi

if [ "$4" = "" ]
then
echo Fourth argument missing on command line
exit 17
fi

if [ $# -gt 4 ]
then
echo Too many arguments provided on command line (>4)
exit 18
fi

# If you get this far, then all the data provided passed all the tests 
#now you can add whatever processing that you want.
echo Argument 1 is $1
echo Argument 2 is $2
...
...
Reply With Quote
Reply

Tags
scripting, shell, unix

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On