Scripting
How do i send input to program?
such as i call dummyprogram and it outputs enter dummyname: how would i send a name into the prorgam? thanks |
Please, be more specific.
What do you really want? Do you want to write your own C program which gets user's input, Or a bash script, or do you just want to redirect something from the terminal to a program (using a |)...? thanks |
echo "yourName" | dummyprogram
|
basically im calling an program that accepts two inputs
such as ./dummy output: enter dummy first name output: enter dummy last name . i want to write a script to do that for me what i got so far #!/usr/bin/expect -- spawn calldummy -someoptions expect "*" send "firstname\r" expect "*" send "lastname\r" but the stuff doesnt seem to pass through properly thanks |
it would be even better if i can do it in c
if it was in C, something like this doesnt work for me system("dummy -options"); system("firstname"); system("lastname"); |
any tips please?
|
echo -e "firstinput\nsecondInput\n" | ./dummyprogram
|
Code:
#!/bin/sh |
echo -e "firstinput\nsecondInput\n" | ./dummyprogram
isnt working i tried /r and /r/n the program i am running is passwd . as in "passwd username" im getting a password do not match . but i ebelieve the input goes through any tips thanks so far |
any help guys? please . thanks.
|
Quote:
Depending the O/S you are running, and you failed to mention that too, passwd is picky about from where its input is coming. However, expect is handling passwd properly so you should keep on searching that way. |
ahhh i see
im running debian linux so i should keep trying expect? |
check the man page of your passwd program whether there's a --stdin option. Think you can give it a try if there is.
|
i have no --stdin option
is it possible somehow to do it in C then? call the passwd and change the password? i can of course write directly to /etc/passwd and /etc/shadow but i want to avoid that and use the passwd command if possible |
No need to use C, I told you you can use expect.
|
All times are GMT -5. The time now is 06:45 PM. |