Sponsored Content
Full Discussion: Expect question
Top Forums Shell Programming and Scripting Expect question Post 302342753 by peterro on Monday 10th of August 2009 04:23:27 PM
Old 08-10-2009
I think you'll want to use send_user instead of send for the "hmmm" message. ftp won't understand what to do with that command.

Code:
expect {
  "No such file or directory" 
    {send_user "hmmm\r" 
      send mkdir whatever_dir 
      send cd whatever_dir }
  "250 CWD command successful"
}
send put whatever_file

Not an expect expert, but I don't think you need anything after the final "250..." line as it will get what it expects, and moves on. Not sure if this is exact or the most efficient, but it should be close.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

question regarding EXPECT

I am rather new to using expect and have only written a few scripts using it. I am trying to create a script that will read a file containing a number of hostnames and then for each one: ssh into the box, run a command, scp the output back to a center server. So far I can make all that... (2 Replies)
Discussion started by: finnje
2 Replies

2. UNIX for Dummies Questions & Answers

expect question

I am trying to write a script that telnets out to multiple ip's, runs some commands exits and the telnets to the next ip. I wrote the following script and it works great until the program hits a nonresponsive ip. I would like this to recognize the ip is bad and move on in the foreach loop. How... (4 Replies)
Discussion started by: pbaets01
4 Replies

3. Shell Programming and Scripting

Question about an expect script

I am using Expect to spawn a command that loops through a text file and runs the same command for each item in the text file. The text file, named stat.txt looks something like this: 2007-04 alist 543 2008-07 blist 543 2008-03 xlist 345 2008-03 ylist 675 2003-03 zlist 567 The expect... (1 Reply)
Discussion started by: manouche
1 Replies

4. Shell Programming and Scripting

two question about expect srcipt

Hi experts, I have two question about expect script questions 1 send "tar -xjvf a.tar\r" send "ifconfig\r" I want to know if it just run "ifconfig after "tar -xjvf a.tar complete. or the two cmd run at the same time question 2 after I use the expect to ssh to the... (1 Reply)
Discussion started by: yanglei_fage
1 Replies

5. Shell Programming and Scripting

Noob Expect Scripting Question

I'm having some difficulty with convincing Expect to do what I need.. I have a loop that waits for input, a specific phrase of text followed by a single word. I need Expect to capture that word following the specific phrase. It should then store the word in a variable. I'm fairly sure it's... (6 Replies)
Discussion started by: LongLeafTea
6 Replies

6. Shell Programming and Scripting

Question to gurus with expect

Hi., I need to ask question for expect script. I have prompt like # and very long script (orachk). I added to expect script line set prompt "(%|#|\\\$) $" and insert into it also piece of code ---- expect { timeout { puts "Running..." exp_continue } ... (0 Replies)
Discussion started by: beckss
0 Replies

7. UNIX for Beginners Questions & Answers

Expect question

I have an expect script that appears to be working normally however for some reason, the remote side appears to be stripping off the variables from the awk command. This is the original: expect \"~]$\" send \"sed 's/=/ /g;s/,/ /g' /home/file.txt | grep abc | awk '{print $6,$8}'This is the... (5 Replies)
Discussion started by: jimmyf
5 Replies

8. UNIX for Beginners Questions & Answers

Expect Question

Have an expect script but can't seem to de-bug it. It's stalling at the password prompt. If anyone can see a mistake, kindly let me know. Thanks. Here is the error: spawn ssh -o StrictHostKeyChecking=no user@xx.xx.xx.xx rpm -qa # Warning! You have entered into a secured area! # # All... (2 Replies)
Discussion started by: jimmyf
2 Replies

9. UNIX for Beginners Questions & Answers

Expect Question

I'm using expect to log into a remote host and then execute another script. A log of the script is being created but I can't see to get the script to display while it's running. Any ideas would be appreciated. Here is the script. #!/bin/bash cd /root cat /root/hostname1.txt | while read... (1 Reply)
Discussion started by: jimmyf
1 Replies
env(1)								   User Commands							    env(1)

NAME
env - set environment for command invocation SYNOPSIS
/usr/bin/env [-i | -] [name=value...] [ utility [ arg... ]] /usr/xpg4/bin/env [-i | -] [name=value...] [ utility [ arg... ]] DESCRIPTION
The env utility obtains the current environment, modifies it according to its arguments, then invokes the utility named by the utility op- erand with the modified environment. Optional arguments are passed to utility. If no utility operand is specified, the resulting environment is written to the standard output, with one name=value pair per line. /usr/bin If env executes commands with arguments, it uses the default shell /usr/bin/sh (see sh(1)). /usr/xpg4/bin If env executes commands with arguments, it uses /usr/xpg4/bin/sh (see ksh(1)). OPTIONS
The following options are supported: -i | - Ignores the environment that would otherwise be inherited from the current shell. Restricts the environment for utility to that specified by the arguments. OPERANDS
The following operands are supported: name=value Arguments of the form name=value modify the execution environment, and are placed into the inherited environment before utility is invoked. utility The name of the utility to be invoked. If utility names any of the special shell built-in utilities, the results are unde- fined. arg A string to pass as an argument for the invoked utility. EXAMPLES
Example 1: Invoking utilities with new PATH values The following utility: example% env -i PATH=/mybin mygrep xyz myfile invokes the utility mygrep with a new PATH value as the only entry in its environment. In this case, PATH is used to locate mygrep, which then must reside in /mybin. ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of env: LANG, LC_ALL, LC_CTYPE, LC_MES- SAGES, and NLSPATH. PATH Determine the location of the utility. If PATH is specified as a name=value operand to env, the value given shall be used in the search for utility. EXIT STATUS
If utility is invoked, the exit status of env is the exit status of utility. Otherwise, the env utility returns one of the following exit values: 0 Successful completion. 1-125 An error occurred. 126 utility was found but could not be invoked. 127 utility could not be found. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: /usr/bin +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |CSI |enabled | +-----------------------------+-----------------------------+ /usr/xpg4/bin +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWxcu4 | +-----------------------------+-----------------------------+ |CSI |enabled | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
ksh(1), sh(1), exec(2), profile(4), attributes(5), environ(5), standards(5) SunOS 5.10 2 Jan 2002 env(1)
All times are GMT -4. The time now is 01:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy