How to command a program after it is started from the script?

How to command a program after it is started from the script?

Post by Colin Theflea » Sat, 17 Nov 2001 07:31:51



I need to enter keyboard commands to a program that is started with the
script. Like press the enter key, or give a number and press enter. I can
do it with the keyboard when the program ask me, but the shell script
should do if for me. I have to start 100 time the same program and give it
always the same command after it is started.

How can I do it with a script???

Many thanks for any idea

Ciao
Colin

 
 
 

How to command a program after it is started from the script?

Post by Barry Margoli » Sat, 17 Nov 2001 08:09:59




Quote:>I need to enter keyboard commands to a program that is started with the
>script. Like press the enter key, or give a number and press enter. I can
>do it with the keyboard when the program ask me, but the shell script
>should do if for me. I have to start 100 time the same program and give it
>always the same command after it is started.

>How can I do it with a script???

command <<EOF
input1
input2
input3
...
EOF

Where input# are the lines that you want to feed as input to the command.

--

Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 
 
 

How to command a program after it is started from the script?

Post by Colin Theflea » Sat, 17 Nov 2001 08:25:22





>>I need to enter keyboard commands to a program that is started with the
>>script. Like press the enter key, or give a number and press enter. I can
>>do it with the keyboard when the program ask me, but the shell script
>>should do if for me. I have to start 100 time the same program and give it
>>always the same command after it is started.

>>How can I do it with a script???

> command <<EOF
> input1
> input2
> input3
> ...
> EOF

> Where input# are the lines that you want to feed as input to the command.

THANKS!

Ciao
Colin

 
 
 

How to command a program after it is started from the script?

Post by Colin Theflea » Sat, 17 Nov 2001 08:40:28





>>I need to enter keyboard commands to a program that is started with the
>>script. Like press the enter key, or give a number and press enter. I can
>>do it with the keyboard when the program ask me, but the shell script
>>should do if for me. I have to start 100 time the same program and give it
>>always the same command after it is started.

>>How can I do it with a script???

> command <<EOF
> input1
> input2
> input3
> ...
> EOF

> Where input# are the lines that you want to feed as input to the command.

Is it possible to introduce a "sleep 1" in between? Or any timing before
the next command?

Thanks
Ciao
Colin

 
 
 

How to command a program after it is started from the script?

Post by Barry Margoli » Sat, 17 Nov 2001 08:46:32







>>>I need to enter keyboard commands to a program that is started with the
>>>script. Like press the enter key, or give a number and press enter. I can
>>>do it with the keyboard when the program ask me, but the shell script
>>>should do if for me. I have to start 100 time the same program and give it
>>>always the same command after it is started.

>>>How can I do it with a script???

>> command <<EOF
>> input1
>> input2
>> input3
>> ...
>> EOF

>> Where input# are the lines that you want to feed as input to the command.

>Is it possible to introduce a "sleep 1" in between? Or any timing before
>the next command?

while read line
do
  echo "$line"
  sleep 1
done <<EOF | command
input1
input2
input3
EOF

If you want to get any more complex than this, you'll probably want to do
it as an Expect script rather than a shell script.

--

Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 
 
 

How to command a program after it is started from the script?

Post by Ben.Altma » Sat, 17 Nov 2001 22:18:38








> >>>I need to enter keyboard commands to a program that is started with the
> >>>script. Like press the enter key, or give a number and press enter. I can
> >>>do it with the keyboard when the program ask me, but the shell script
> >>>should do if for me. I have to start 100 time the same program and give it
> >>>always the same command after it is started.

> >>>How can I do it with a script???

> >> command <<EOF
> >> input1
> >> input2
> >> input3
> >> ...
> >> EOF

> >> Where input# are the lines that you want to feed as input to the command.

> >Is it possible to introduce a "sleep 1" in between? Or any timing before
> >the next command?

> while read line
> do
>   echo "$line"
>   sleep 1
> done <<EOF | command
> input1
> input2
> input3
> EOF

> If you want to get any more complex than this, you'll probably want to do
> it as an Expect script rather than a shell script.

Or you could use co-processes in ksh.
 
 
 

How to command a program after it is started from the script?

Post by Lekeas G » Sun, 18 Nov 2001 01:54:57


Hi,

You can try writing an Expect script.

George


> Date: Fri, 16 Nov 2001 08:18:38 -0500

> Newsgroups: comp.unix.shell
> Subject: Re: How to command a program after it is started from the script?







> > >>>I need to enter keyboard commands to a program that is started with the
> > >>>script. Like press the enter key, or give a number and press enter. I can
> > >>>do it with the keyboard when the program ask me, but the shell script
> > >>>should do if for me. I have to start 100 time the same program and give it
> > >>>always the same command after it is started.

> > >>>How can I do it with a script???

> > >> command <<EOF
> > >> input1
> > >> input2
> > >> input3
> > >> ...
> > >> EOF

> > >> Where input# are the lines that you want to feed as input to the command.

> > >Is it possible to introduce a "sleep 1" in between? Or any timing before
> > >the next command?

> > while read line
> > do
> >   echo "$line"
> >   sleep 1
> > done <<EOF | command
> > input1
> > input2
> > input3
> > EOF

> > If you want to get any more complex than this, you'll probably want to do
> > it as an Expect script rather than a shell script.

> Or you could use co-processes in ksh.

 
 
 

How to command a program after it is started from the script?

Post by Barry Margoli » Sun, 18 Nov 2001 04:28:02




Quote:>You can try writing an Expect script.

Isn't that what I wrote right here in the message you quoted:

Quote:>> > If you want to get any more complex than this, you'll probably want to do
>> > it as an Expect script rather than a shell script.

--

Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
 
 
 

1. how to kill a program in a script that started from that script

Hi,
Thanks from the previous answers from my how to kill without redirection
to file. Now I get to the next step and again I need help or suggestions.

The problem is this makefile...

all:
         /Applications/iTunes.app/Contents/MacOS/iTunes
         kill -9 $( ps | grep "iTunes" | cut -f1 -d\  )

So, iTunes started, and from a different shell I can execute
the next line no problem. But if I want to execute from same
shell then I can't, not unless I hit ctrl-Z manually.

Any suggestions.

Thanks.

2. Reading is much more interesting than TV (1008/1708)

3. Script command in shell script program ?

4. ufsdump archive --> tar archive ?

5. Programming an "WHO AM I" command

6. Is linux faster than windows

7. I am looking for a way to update passwords via program or script

8. tcpdump: how to make a socket only look at one ethernet card

9. starting script file with ksh for rsh commands

10. Need full path to start a script or program

11. PID of the program my shell script just started?

12. Can't start shell scripts by another program

13. how do I pass commands from a script to a program?