Automatic input to commands


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Automatic input to commands
# 1  
Old 06-21-2007
Automatic input to commands

Hi,

In a shell script i am running a command which is asking for input.

How can i give that automatically.

I have done this before but for the time being can't recall.
Was something like <|

Thanks
# 2  
Old 06-21-2007
The "<" operator is used to pipe a file to stdin for a program.

The "|" operator is used to pipe the output of another program into the input of a program.

The "<<" operator pipes the following data upto a end of string token

eg

Code:
cat <somefile

or

Code:
echo "banana" | cat

or

Code:
cat <<EOF
hello world
EOF

# 3  
Old 06-21-2007
Yes,

Okay i'll give an example.

Suppose i want to run the format command via shell script.

Now it will ask for inputs, that i want to automatically give it.
# 4  
Old 06-21-2007
Lemme give the exact situation.

Its the "cvs login" command.


Want to do a lot of things in a shell script.
The first step is the login of cvs.

It asks for input, how can i give it automatically.
# 5  
Old 06-21-2007
logins are a different kettle of fish as often instead of reading stdin they read from /dev/tty.

That said, I thought cvs logins were persistent.
# 6  
Old 06-22-2007
So,

Isn't there any option to make them read from dev/tty

We can redirect the same to dev/tty
# 7  
Old 06-01-2008
spawn ssh <xserver> <a command>
expect "password:"
send "$password\r"
expect eof


you gotta have /usr/lib/spawn /usr/lib/expect /usr/lib/send
just goto the prompt and type
whereis spawn; whereis expect; whereis send..

I am looking for these files too.

If you are in HP-UX, you probably get this error message and your <expect> will not work
/usr/lib/dld.sl: Can't find path for shared library: libtcl.sl
/usr/lib/dld.sl: No such file or directory
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Automatic input "yes" in a shell script

Hi All, I need a favour. I have a file called "redhat_servers.txt" containing some server names line by line. When I try to ssh to each server, and I have already done with ssh key-gen stuff. Now, for first time if I do ssh .. I need to type yes I have more than 400 servers...it will take... (4 Replies)
Discussion started by: kumar85shiv
4 Replies

2. Shell Programming and Scripting

[KSH] Creating automatic variable from read input

Hello there, I am posting to seek help with a KSH script, I am making a simple calculation program where the user can enter as many numbers as they like, I am getting their input using the read command, however I am not sure how to repeat doing this and storing the input in to new variables... (7 Replies)
Discussion started by: pandapowerbox
7 Replies

3. Shell Programming and Scripting

How to take input from the user from the command line and execute commands basedon that?

Hi, I am using solaris 10 and bash shell.Script execution follows below.Initially it will check whether a directory exists or not if does not exist it will create it.(This I have completed) Second step:I have four users say user1,user2,user3,user4.Script should prompt for the user id and... (11 Replies)
Discussion started by: muraliinfy04
11 Replies

4. Shell Programming and Scripting

Automatic Input to a command

Hi, I have an issue where i run an command in a shell script. command >/dev/null ret=$? echo ret If the command returns an error i'm redirecting it to /dev/null. The prob is if an error comes it expects the user to press return to continue. And hence the return is not echoed. and the end... (4 Replies)
Discussion started by: subhrap.das
4 Replies

5. Shell Programming and Scripting

Giving automatic multiple Input to a tool from shell script

Hi, Please help me,its urgent. I have a tool that i want to run from a shell script. When we run the tool it will ask the user choice to add or delete. When user enter the choice it will then ask how many units he want to delete or add and will add or delete accordingly. Now I want to... (1 Reply)
Discussion started by: saket18@ymail.c
1 Replies

6. Shell Programming and Scripting

Help to write a script or program to automatic execute and link input file data

Output file template format <input_file_name>a</input_file_name> <total_length_size>b</total_length_size> <log_10_length_size>c</log_10_length_size> Input_file_1 (eg. sample.txt) SDFSDGDGSFGRTREREYWW Parameter: a is equal to the input file name b is equal to the total length of... (2 Replies)
Discussion started by: perl_beginner
2 Replies

7. Shell Programming and Scripting

Execute commands to specific folder from input file

Hi, I have one text file input.txt, which has folders path as follows: /home/user/automate/abc /home/user/automate/abc/xyz /home/user/automate/test /home/user/automate/test2 /home/user/automate/test2/abc/Main In those folders i have .svn folder. 1) First i want to remove .svn like rm... (5 Replies)
Discussion started by: dragon.1431
5 Replies

8. Shell Programming and Scripting

Automatic file input to code

i have got many files like this in my folder temp(say) imp_02042008.txt for date 02-04-2008 imp_03092009.txt for date 03-09-2009 imp_25112009.txt for date 25-11-2009 ................... ........ in some folder. and one of my shell code uses one of the above files based on date.... (9 Replies)
Discussion started by: Maruti
9 Replies

9. Shell Programming and Scripting

[code] Automatic File Input

i have got many files like this in my folder temp(say) imp_02042008.txt for date 02-04-2008 imp_03092009.txt for date 03-09-2009 imp_25112009.txt for date 25-11-2009 ................... ........ in some folder. and one of my shell code uses one of the above files based on date.... (0 Replies)
Discussion started by: Maruti
0 Replies

10. HP-UX

Automatic execution of commands in multiple servers using single script.

Hi, I've to do a simple job many times whenever it has been asked, just i've to log in to all of fourtien HP servers and i've to execute ps -fu user > temp cat temp|sendmail "xyz@z.com" commands to send the statics of all of 14 servers over the mail to particular user id.. Though logging... (4 Replies)
Discussion started by: vickramshetty
4 Replies
Login or Register to Ask a Question