UNIX - Reading the input to a shell Scrip from a File

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SANDY1722
    New Member
    • Sep 2007
    • 6

    UNIX - Reading the input to a shell Scrip from a File

    Hi,

    I have a shell script, test.ksh which should read the input from another file, say 1.txt

    test.ksh:

    #!/usr/bin/ksh

    datasource=$1

    echo "Data is: $datasource


    1.txt:

    12345

    When I run the command:

    $test.ksh < 1.txt

    It does not read the varibale properly from the file.

    The scrip works fine when I type:

    $test.ksh 12345


    Thanks for help.
  • coaxfiber
    New Member
    • Mar 2007
    • 60

    #2
    Originally posted by SANDY1722
    Hi,

    I have a shell script, test.ksh which should read the input from another file, say 1.txt

    test.ksh:

    #!/usr/bin/ksh

    datasource=$1

    echo "Data is: $datasource


    1.txt:

    12345

    When I run the command:

    $test.ksh < 1.txt

    It does not read the varibale properly from the file.

    The scrip works fine when I type:

    $test.ksh 12345


    Thanks for help.
    Hi try this one,
    --------------------------------------
    #!/bin/ksh

    1.txt > datasource
    one=$(cat datasource)
    echo "Date is: $one"
    --------------------------------------

    Comment

    Working...