Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2011
    Posts
    3

    Unanswered: 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 14:10.

  2. #2
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    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 16:55.

  3. #3
    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..

  4. #4
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    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
    ...
    ...

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •