Sign in to follow this  
Followers 0
StankDawg

Control code for <ENTER>

5 posts in this topic

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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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. <_<

Share this post


Link to post
Share on other sites

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. -_-

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0