Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2004
    Posts
    2

    Unanswered: can i stored @@servername as a variable?

    isql -S$entry -Uuser -Ppwd -w200 <<- !END
    select @@servername
    go
    quit
    !END
    return=$?

    can i stored @@servername as a variable?
    i would like to echo its value in the later part of my shell script

  2. #2
    Join Date
    Aug 2004
    Posts
    18
    What Sybase database? If ASA, you can easily do that by SELECTing INTO a host variable. ASE probably has an equivalent, but I don't know what it would be.

  3. #3
    Join Date
    Aug 2004
    Posts
    42
    You want a shell variable, right? Try:

    LOG=MyLogFile
    isql -S$entry -Uuser -Ppwd -w200 -o $LOG <<- !END
    select @@servername, "QWERTY"
    go
    quit
    !END
    SERVERNAME=`grep QWERTY var.sh.log | cut -d " " -f 2`
    echo $SERVERNAME

    return=$?

    I made these changes to your script:

    1. Added definiation of LOG variable as name of output file of isql.
    2. Added -o $LOG to isql line.
    3. Added the constant "QWERTY" to the select list that includes @@servername so that we can easily distinguish this line with grep.
    4. Set SERVERNAME using grep and cut and the tick <`> quotes that put stdout into a shell variable.
    5. Note the -d " " and -f 2 options for cut. The first make space the delimiter. The second says to take the 2nd field. It's the 2nd because there is a space before the first column of printed output.

  4. #4
    Join Date
    Aug 2004
    Posts
    2

    thanks

    thanks a lot, Tad Hawkins!

Posting Permissions

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