Sponsored Content
Top Forums Programming Calling expect script inside another expect Post 302691803 by Corona688 on Saturday 25th of August 2012 07:23:23 PM
Old 08-25-2012
What are you trying to do?

Why do you need to?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Calling an Expect script from a Webpage using PHP

I have a webpage that is in HTML and PHP. In PHP I have tried using exec, system, shell_exec and passthru functions to call an Expect Script file (temp.exp). This Expect file spawns a telnet session that uses "expect/send" commands to retrieve information from an environmental unit (not a normal... (0 Replies)
Discussion started by: CCUSmith
0 Replies

2. Shell Programming and Scripting

Calling Expect script in Perl...

I call a EXPECT script from my perl script with machine IP and a FIle. The script logins to the machine and exports the value. The values to be exported or stored in a file. I have close to 10 machines and I have created 10 files and pass the corresponding files in command line, Now I could like... (4 Replies)
Discussion started by: ramkriz
4 Replies

3. Shell Programming and Scripting

calling expect script in ksh is failing via cron

I'm calling an expect script via a ksh script in cron and it is failing. The script runs fine if i run it manually. Does anyone know if it is an issue with compatibilty and if there is a way around it? (2 Replies)
Discussion started by: bhatia
2 Replies

4. Shell Programming and Scripting

ssh is not working while calling through expect shell script

Hi, Please share you experience and way out on below error:--> #!/bin/bash -xv FILE=login.txt + FILE=login.txt CONNECT=sshlogin.exp + CONNECT=sshlogin.exp SERVERNAME=$1 + SERVERNAME=192.168.12.1 MyServer="" + MyServer= MyUser="" + MyUser= MyPassword="" + MyPassword= exec 3<&0 +... (6 Replies)
Discussion started by: manish_1678
6 Replies

5. Shell Programming and Scripting

Calling Shell Script from Expect...

Hi there, I need some help regarding the execution of shell script from expect as the method I am trying is giving me error. I wrote an shell program which takes two arguments to telnet to a device and saves the output in a file. Following is the script.... (0 Replies)
Discussion started by: cyberparanoid
0 Replies

6. Shell Programming and Scripting

Calling Expect Script - Telnet

Hi All, I have an Expect script which logs into Cisco switch, performs a show interface command. I want to read a file of ip addresses which will be passed to the expect script. The script to read the file works, the expect script works on it's own but when i call the 'expect' script from the... (12 Replies)
Discussion started by: trinak96
12 Replies

7. Shell Programming and Scripting

Calling a function which uses expect from a shells script

Hi all, This is the first time i am using expect. I am trying to call a function with in the shell script. The function will shh to a new server and will pass the password using expect and send. I need help in calling the fuction i am getting follaowing errors... here the script ... (8 Replies)
Discussion started by: firestar
8 Replies

8. Programming

Calling another expect script inside an expect script

I have an expect script called remote that I want to call from inside my expect script called sudoers.push, here is the code that is causing me issues: set REMOTE "/root/scripts/remote" ... log_user 1 send_user "Executing remote script as $user...\n" send_user "Command to execute is: $REMOTE... (1 Reply)
Discussion started by: brettski
1 Replies

9. Shell Programming and Scripting

Password check in bash script calling on expect

password check in bash script calling on expect Background: I have to copy a file from one server, to over 100 servers in a test environment. once the file is copied, it requires to have the permissions on the file changed/verified. These are all linux servers. most of them have the same... (1 Reply)
Discussion started by: 2legit2quit
1 Replies

10. UNIX for Advanced & Expert Users

Calling expect from shell script which inturn call python

Hi Team, I have to execute a task from my local machine, where i keep my .expect,.sh, .bash and .python scripts .Task are coded in the script and has to be executed at remote machine. for that i used following task ..... SCRIPT 1: cat shell_check.sh read value if then expect... (3 Replies)
Discussion started by: Sivarajan N
3 Replies
EXPECT_EXPECTL(3)							 1							 EXPECT_EXPECTL(3)

expect_expectl - Waits until the output from a process matches one of the patterns, a specified time period has passed, or anEOFis seen

SYNOPSIS
int expect_expectl (resource $expect, array $cases, [array &$match]) DESCRIPTION
Waits until the output from a process matches one of the patterns, a specified time period has passed, or an EOF is seen. If $match is provided, then it is filled with the result of search. The matched string can be found in $match[0]. The match substrings (according to the parentheses) in the original pattern can be found in $match[1], $match[2], and so on, up to $match[9] (the limitation of libexpect). PARAMETERS
o $expect - An Expect stream, previously opened with expect_popen(3). o $cases - An array of expect cases. Each expect case is an indexed array, as described in the following table: Expect Case Array +----------+--------------------------+---+---+---+ |Index Key | | | | | | | | | | | | | Value Type | | | | | | | | | | | | Description | | | | | | | | | | | | Is Mandatory | | | | | | | | | | | | Default Value | | | | | | | | | | +----------+--------------------------+---+---+---+ | 0 | | | | | | | | | | | | | string | | | | | | | | | | | | pattern, that will be | | | | | | matched against the out- | | | | | | put from the stream | | | | | | | | | | | | yes | | | | | | | | | | | | | | | | | | T{ 1 | | | | | | | | | | | | mixed | | | | | | | | | | | | value, that will be | | | | | | returned by this func- | | | | | | tion, if the pattern | | | | | | matches | | | | | | | | | | | | yes | | | | | | | | | | | | | | | | | | T{ 2 | | | | | | | | | | | | integer | | | | | | | | | | | | pattern type, one of: | | | | | | EXP_GLOB, EXP_EXACT or | | | | | | EXP_REGEXP | | | | | | | | | | | | no | | | | | | | | | | | | | | | | | | EXP_GLOB | | | | | | | | | | +----------+--------------------------+---+---+---+ RETURN VALUES
Returns value associated with the pattern that was matched. On failure this function returns: EXP_EOF, EXP_TIMEOUT or EXP_FULLBUFFER CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 0.2.1 | | | | | | | Prior to version 0.2.1, in $match parameter a | | | match string was returned, not an array of match | | | substrings. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 expect_expectl(3) example <?php // Copies file from remote host: ini_set("expect.timeout", 30); $stream = fopen("expect://scp user@remotehost:/var/log/messages /home/user/messages.txt", "r"); $cases = array( // array(pattern, value to return if pattern matched) array("password:", "asked for password"), array("yes/no)?", "asked for yes/no") ); while (true) { switch (expect_expectl($stream, $cases)) { case "asked for password": fwrite($stream, "my password "); break; case "asked for yes/no": fwrite($stream, "yes "); break; case EXP_TIMEOUT: case EXP_EOF: break 2; // break both the switch statement and the while loop default: die "Error has occurred!"; } } fclose($stream); ?> SEE ALSO
expect_popen(3). PHP Documentation Group EXPECT_EXPECTL(3)
All times are GMT -4. The time now is 08:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy