![]() |
|
|
|
|
|||||||
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Script(s) to Automate Tasks | droppedonjapan | Shell Programming and Scripting | 2 | 05-21-2008 07:32 AM |
| automate sftp using unix script | priyamurthy2005 | Shell Programming and Scripting | 32 | 04-17-2008 05:29 AM |
| script to automate mksysb via nim in AIX 5.3 | barkath | Shell Programming and Scripting | 0 | 12-20-2007 02:46 PM |
| here document to automate perl script that call script | hogger84 | Shell Programming and Scripting | 3 | 10-22-2007 07:15 AM |
| Script to automate file comparisons | herman404 | Shell Programming and Scripting | 6 | 03-17-2005 04:52 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
I have a program that i have to run by cron. The program needs user input. So i have to automate that in a littke script.
start of script program.sh: result=program.log; export result echo Program starting : `date` >> $result /usr/local/program >> $result echo Program running : `date` >> $result The program normally asks for a string (a pass phrase). How can i do this ? I know i have to use something like : /usr/local/program >> $result 2>&1 <<eof blablablabla eof but i don't get it to work Thanks in advance |
| Forum Sponsor | ||
|
|
|
|||
|
automate the input
I tried a lot of things. When i start quoting i always get messages of command not found. I treid normal single quote ', double quote " and single right quote ` and single left quote ´. Which one should i be using ? Do i have to quote the whole line ? I tried the whole line and parts of the line. I tried to put the blahblah on the same line . When i use : program <> $result 2>&1 << blahblah the output is coming to my screen When using spaces between the < < then i get syntax errors near the unexpected token < Most of the times it keeps waiting for the input. When i enter the string (stays invisible to me) the program starts without problem. |
|
||||
|
Check out expect: http://expect.nist.gov
You can supply interactive data in a script... |
|
|||
|
Hello, thanks for your time, but still no solution
when i try program << eof >> $result 2>&1 answer1 eof the program just sits waiting. When i type the answer1-string myself, everything goes well. I installed expect (and tcl --> both latest versions) and tried the following script : #!/usr/local/bin/expect send_user "start expect\r" spawn PROGRAM expect "pass phrase:" send "answer1\r" send_user "stop expect\r" This doesn't work either --> the program gets started, but finishes after displaying the question to enter the pass phrase. The start en stop expect doesn't appear on screen also. Has the fact that when in normal mode (outside a script) the pass phrase is entered it doesn't appear on the screen (password-like) ? Thanks in advance Erwin |
|
||||
|
Expect is very literal in what it expects...
A single space can ruin an entire script. You might get lucky using wildcards, like so: expect "*pass phrase:*" Just be careful not to use too many, in case you match another line somewhere... Also, make sure you are getting the case correct; "Pass" does not equal "pass" |
|
||||
|
May I ask what "program" actually is?
It seems from your post that it is some sort of program that requires a user authentication (or password). Many programs like this woun't let you redirect the standard input by default but many also provide other options to allow this sort of redirection. In general, this is done for security reasons (like the passwd program itself). |
||||
| Google UNIX.COM |
| Thread Tools | |
| Display Modes | |
|
|
|
The 50 most popular UNIX and Linux searches.
Google Search Cloud for The UNIX and Linux Forums
|
| 421 service not available, remote server has closed connection ^m automate ftp autosys awk trim bash eval bash for loop boot: cannot open kernel/sparcv9/unix command copy/move folder in unix couldn't set locale correctly curses.h cut command in unix find grep find mtime find null character in a unix file grep multiple lines grep or grep recursive hp-ux ifconfig inaddr_any inappropriate ioctl for device lynx javascript mailx attachment mget mtime ping port remove first character from string in k shell replace space by comma , perl script rsync ftp scp recursive segmentation fault(coredump) sftp script snoop unix solaris change ip address stale nfs file handle syn_sent tar exclude tar extract to folder test: argument expected unix unix .profile unix forum unix forums unix internals unix interview questions unix mtime unix simulator unix.com vi substitute while loop within while loop shell script |