Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2003
    Posts
    1

    Question Unanswered: invoking a carriage return in a shell script

    Hello all,

    I am echoing a number of parameters into a control file for use later in my script. The program requires a carriage return after parameter entry, in order for it to continue with the next question.

    Does anyone know how I can supply a carriage return in my control file. In other words I need to reproduce a keyboard entry of Carriage Return to my program via my control file parameters.


    echo "1" >> $cntr

    echo "yes" >> $cntr

    echo "no" >> $cntr

    program < $cntr

    Thanks in advance...
    Last edited by ldcoldwell; 08-27-03 at 12:31.

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Post

    Try:

    echo "\n" >> $cntr

    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  3. #3
    Join Date
    Aug 2003
    Location
    Italy
    Posts
    3
    you can also try

    echo "" >> $cntr

    Gus ;-)

  4. #4
    Join Date
    Jun 2002
    Location
    UK
    Posts
    525
    Can't you just echo your 'answers' in to the program rather than write them to a file?

    e.g.

    ----------------------------

    # prog.sh

    read ans1
    read ans2
    read ans3

    echo ans1 is $ans1
    echo ans2 is $ans2
    echo ans3 is $ans3

    ----------------------------


    echo "yourAnswer1\nyourAnswer2\nyourAnswer3" | prog.sh


    Or without the echo...

    prog.sh << !!
    yourAnswer1
    yourAnswer2
    yourAnswer3
    !!

    Last edited by Damian Ibbotson; 08-28-03 at 10:46.

Posting Permissions

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