Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2003
    Posts
    1

    Unanswered: unix shell scripting question

    me
    trying to run a select statment
    select * from x >a.txt
    this does not work
    wheras
    select * from x works

    What is teh redirection operator required

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    Re: unix shell scripting question

    Just a thought ....

    Can you have your statement within quotes
    "select * from x" > a.txt

    Originally posted by adip
    me
    trying to run a select statment
    select * from x >a.txt
    this does not work
    wheras
    select * from x works

    What is teh redirection operator required

  3. #3
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713
    In unix shell sript you can do something like this:

    #!/bin/ksh
    sqlplus <usr>/<pw> <<!
    spool a.txt
    select * from x;
    spool off
    exit
    !

    And also like this:

    #!/bin/ksh
    sqlplus <usr>/<pw> <<! >a.txt
    select * from x;
    exit
    !
    Last edited by LKBrwn_DBA; 07-10-03 at 12:46.

  4. #4
    Join Date
    Jul 2003
    Location
    US
    Posts
    314

    Scripting

    If u are using sqlplus, kindly use the following command and you would be fine with the same.

    script a.txt
    sqlplus user /password
    select fname, lname, orderid from prod_table;
    quit
    exit

    now you can do a
    cat a.txt
    cat a.txt | mail user@domain.com

  5. #5
    Join Date
    Dec 2002
    Posts
    104
    another solution

    isql -U<username> -P<pwd> -S<servername> -D<dbname> -oa.txt <<-EOF
    select * from table
    go
    EOF

    Pooja

Posting Permissions

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