Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2003
    Location
    India
    Posts
    262

    Unanswered: Accept input parameters

    Dear All,

    I got a table creation file in a standard format. I need to accept parameters from the user & then based on the input change the data in the file. For. eg.
    i will accept the database name, dbspace name & user name from the user and accordingly change the same in the table creation file. Any ideas???.
    Thanks in advance.

    Regards,

    lloyd

  2. #2
    Join Date
    Oct 2003
    Posts
    19
    You can do this in many ways .
    1. Pass the arguments on the command line and access values as $1 $2 etc from inside the script .
    2. For a more descriptive solution you can use the
    <script> -d <dbname> -u <username> and so on and access the values using the getopts command inside the script.
    3. You can also store the configurable values in a file and read the file before invoking the table creation script.
    Let me know if you need any further help

    Thanks
    Saurav

  3. #3
    Join Date
    Aug 2003
    Location
    India
    Posts
    262
    Hi Saurav,

    Thanks for your reply, can you pls. give me an eg. of it. I need to accept these parameters & based on the input reflect the changes in the other file(table creation file). My script would be -
    <script> -d <dbname> -u <username> -dbs <dbspace>
    can you give an eg of the above. At the prompt user will enter
    <script> -d <dbname> -u <username> -dbs <dbspace> and based on the input i will change the table creation script using sed command. Thanks in advance.

    Regards,

    lloyd

  4. #4
    Join Date
    Aug 2004
    Location
    Rome, Italy
    Posts
    81
    normally you have to use the one character options, so:
    script -d <dbname> -u <user> -c <dbstring>

    Inside of the script you must have this first instructions:

    while getopts "d:u:c:" opt
    case
    d)DBNAME=$OPTARG;;
    u)USERNAME=$OPTARG;;
    c)DBSTRING=$OPTARG;;
    ])echo "Wrong Option Applied: " $opt; exit 0;;
    esac
    done

  5. #5
    Join Date
    Aug 2003
    Location
    India
    Posts
    262
    Hi ducasio,

    thanks for the script.

    Regards,

    lloyd

  6. #6
    Join Date
    Aug 2004
    Location
    Rome, Italy
    Posts
    81
    Pleased to be useful

Posting Permissions

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