Skip to contentSkip to conversation

writing a script to simulate keyboard input

DISCUSSION Karthik Vishwanath 4 participants 4 messages Jul 19, 2007 – Jul 20, 2007

lore
Share & tools
lore
#0 lore raw

Hello,

I have to use an archaic, menu-driven C program that requires keyboard input to process commands (all of these commands are terminated by a newline)

I was wondering if there was any way I could use the program within a script so that I could have the script "feed" in the sequence of keystrokes/string-inputs that I must otherwise type in manually?

As ever, all help/advice is appreciated.

Thanks,

-K

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

#1 lore raw
Quoted 11 lines · Karthik Vishwanath

Hello,

I have to use an archaic, menu-driven C program that requires keyboard input to process commands (all of these commands are terminated by a newline)

I was wondering if there was any way I could use the program within a script so that I could have the script "feed" in the sequence of keystrokes/string-inputs that I must otherwise type in manually?

As ever, all help/advice is appreciated.

Have you seen Perl's expect module?

Quoted 10 lines

Thanks,

(quoted diff) +0 -2
-K
 
-

To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Signature · 8 lines
Thanks,

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
#2 lore raw
In reply to Karthik Vishwanath
Quoted 18 lines · Karthik Vishwanath

Hello,

I have to use an archaic, menu-driven C program that requires keyboard input to process commands (all of these commands are terminated by a newline)

I was wondering if there was any way I could use the program within a script so that I could have the script "feed" in the sequence of keystrokes/string-inputs that I must otherwise type in manually?

As ever, all help/advice is appreciated.

Thanks,

(quoted diff) +0 -2
-K
 
-
Quoted 4 lines

To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.linux-learn.org/faqs

As far as I know, this greatly depends on the C program you are trying to use.
But one thing that doesn't hurt trying, is to pipe it with an echo command, for instance
echo "command string" | ./program
A pratical example would be to actually count how many leters you have in abcdef, for this, execute this
echo "abcdef" | wc -c
The | will execute the command that's after the | with the output (I think) of what's on the left of the |

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

#3 lore raw
In reply to Karthik Vishwanath
Quoted 14 lines · Karthik Vishwanath

Hello,

I have to use an archaic, menu-driven C program that requires keyboard input to process commands (all of these commands are terminated by a newline)

I was wondering if there was any way I could use the program within a script so that I could have the script "feed" in the sequence of keystrokes/string-inputs that I must otherwise type in manually?

As ever, all help/advice is appreciated.

Thanks,

(quoted diff) +0 -2
-K
 
-
Quoted 8 lines

To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Signature · 2 lines
This email has been verified as Virus free
Virus Protection and more available at http://www.plus.net

Expect - http://expect.nist.gov/
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs