Jump to content


Photo
- - - - -

Control code for <ENTER>


  • Please log in to reply
4 replies to this topic

#1 StankDawg

StankDawg

    same old Dawg, no new tricks

  • Moderating Team
  • 8,073 posts
  • Country:
  • Gender:Male

Posted 21 May 2003 - 10:37 AM

I have a shell script that executes some SQL commands. these commands rely on a response form the user to continue. The response is always the same ("N" for new) and I want to automate the process to be able to run as a chron job.

EXAMPLE:
@test.sql < PARMS.txt

This works where @test.sql is the program/SQL script and the input "N" is contained by the file "PARMS.txt". I do not want to have to make PARMS.txt however, since this script will be duplicate din many directories and each response may be different. Sometimes PARMS.txt may need to contains "O" for old or somethign like that.

So what I am looking for is a solution that look something like this (which DOES NOT WORK):

EXAMPLE
@test.sql < N\n

I thought "\n" was the control character, but it does not like that. Does anyone see where I am trying to go with this and why it does not work? any help would be appreciated.

#2 ntheory

ntheory

    data pillager

  • Agents of the Revolution
  • 1,757 posts

Posted 21 May 2003 - 11:21 AM

Something like this?

echo "N" | @test.sql

I'm a little cloudy on the exact application so I can't be sure that's what you want. If not, do you have any more information you can give us?

#3 StankDawg

StankDawg

    same old Dawg, no new tricks

  • Moderating Team
  • 8,073 posts
  • Country:
  • Gender:Male

Posted 21 May 2003 - 12:17 PM

yes, I tried that exact thing and it did not work either. I also tried
echo "N\n" | @test.sql
and it did not work etiher.

But yes, you are barking up the right tree.

#4 ntheory

ntheory

    data pillager

  • Agents of the Revolution
  • 1,757 posts

Posted 21 May 2003 - 12:29 PM

Hey, I think I can help you out. I checked the echo man page and there's a "-e" switch on Linux that interprets those characters. Might be similar on your OS.

I tried echo -e "N\n" and it does print N with a genuine newline instead of printing the literal string "N\n".

Hope that'll do the job. <_<

#5 StankDawg

StankDawg

    same old Dawg, no new tricks

  • Moderating Team
  • 8,073 posts
  • Country:
  • Gender:Male

Posted 21 May 2003 - 04:30 PM

yeah, I tried a lot of different combinations of that...

AS it turns out, I got so frustrated that I took the source code of the program being called, and rewrote it. I removed the prompts and hardcoded the variables so that it doesn't even prompt at all! heh-heh... Just because they wrote it that way, doesn't mean I can't hack it to be my bitch!

I will still investigate the other way, but only because the other programmers here will need to do similar things with their processes and I don't want to try and explain what I did to them. -_-




BinRev is hosted by the great people at Lunarpages!