Expect script strange behaviour


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Expect script strange behaviour
# 1  
Old 10-15-2009
Expect script strange behaviour

Hi people,

I'm having some strange behaviour with an 'expect' script.


Code:
spawn csession blah
expect "Username: "
send "userblah\r"
expect "Password: "
send "passwordblah\r"
interact



When I execute the script as root it runs perfectly.

However, when executed as any other user, it appears to send the 'send' commands twice.

Well, I can only assume it is sending twice and not just sending it late as the script successfully logs in but then after approx 5-10 secs it sends 'userblah' and then 'passwordblah' to the application that it has already logged into. Smilie



Any ideas ?

Many thanks in advance for any answers.

---------- Post updated at 06:44 PM ---------- Previous update was at 05:46 PM ----------

Just added a sleep into the script after supplying the password and I can see more strange behaviour (once again not when executed as root)

Here is what happens when ran as root:

spawn csession blah

Username: userblah
Password: passwordblah

application command line:



But when ran as another user:

spawn csession blah

application command line: userblah




As you can see, the username and password does not even appear as the other user, in fact not even the prompt to put it in appears, but it must be being entered however, because you cannot get into the application without a correct username and login (I have tested this by logging into the app manually using the same commands as in the script and you MUST put then in) or you get 'Access Denied'.


This is doing my head in !Smilie

Last edited by radoulov; 10-16-2009 at 05:42 AM.. Reason: please use code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Strange Script behaviour with Grep

Here is my script LOGDATE=`date '+%Y-%m-%d %k:%M' | cut -c1-15` echo $LOGDATE echo "grep '$LOGDATE' /tmp/logs/vel.log >10min_log" grep '$LOGDATE' /tmp/logs/vel.log>10min_log grep '$LOGDATE' /tmp/logs/vel.logHere is the output of the script -rw-r--r-- 1 wluser wluser 0 May 3... (7 Replies)
Discussion started by: mohtashims
7 Replies

2. Shell Programming and Scripting

Odd behaviour with Expect password update script

Hi there. I've been forced by circumstance to write an expect script to handle password updates on a number of servers. There's a mix of Solaris 8, 9, 10, RedHat and Ubuntu. There's no chance the client will allow us to hook them up to a directory, so we have to make do. This script is mostly... (0 Replies)
Discussion started by: whetu
0 Replies

3. Shell Programming and Scripting

strange behaviour script terminate before complete execution

I'm working on a script to make backup of various folder located on various host using different OS. I got a strange behaviour because the script donět process all lines of a configuration file, the script execute only one loop even the input file have 6 lines: This is the script: #!/bin/bash... (4 Replies)
Discussion started by: |UVI|
4 Replies

4. Shell Programming and Scripting

Strange RegExp Behaviour

Hello, I was trying to identify lines who has a word of the following pattern "xyyx" (where x, and ys are different characters). I was trying the following grep - egrep '(\S)()\2\1' This pattern do catches the wanted pattern, but it also catches "GGGG" or "CCCC" patterns. I was trying to... (5 Replies)
Discussion started by: itskov
5 Replies

5. Shell Programming and Scripting

Strange behaviour with perl i/o?

Hi All, I got a strange problem here. I have a perl script which is fetching data from a database table and writing a file with that data. If i run that script from linux command line, the file it creates is a normal ascii text file without any binary character in it.But... (9 Replies)
Discussion started by: DILEEP410
9 Replies

6. Shell Programming and Scripting

strange expect script behavior, or am i misunderstanding expect scripting?

Hello to all...this is my first post (so please go easy). :) I feel pretty solid at expect scripting, but I'm running into an issue that I'm not able to wrap my head around. I wrote a script that is a little advanced for logging into a remote Linux machine and changing text in a file using sed.... (2 Replies)
Discussion started by: v1k0d3n
2 Replies

7. Shell Programming and Scripting

Strange behaviour from script in crontab

Apologies if this has been mentioned elsewhere, my search skills may be lacking somewhat today. I have a script that does the following (as a test): find . -name "*.txt" -exec file {} \; >>$sFullFilePath Now, the variable is set up up correctly in the script too. When I run the script... (1 Reply)
Discussion started by: PilotGoose
1 Replies

8. Shell Programming and Scripting

A Strange Behaviour!!!

Can some-one give me a view to this : I have a directory in an unix server, having permissions r-xr-xr-x .This directory is basically a source directory. Now there is another directory basically the destination directory which has all the permissions. Note:I log in as not the owner,but user... (5 Replies)
Discussion started by: navojit dutta
5 Replies

9. Linux

/etc/passwd strange behaviour!

Hi there, first of all, here is my conf of a uname -a Linux SAMBA 2.4.18-4GB #1 Wed Mar 27 13:57:05 UTC 2002 i686 unknown on a fedora machine. Here is my problem: every once in a while, the line containing root disappears in the /etc/passwd, disabling all logging on my server. Any one have... (0 Replies)
Discussion started by: penguin-friend
0 Replies
Login or Register to Ask a Question