hi all,
i have been trying to get a script working that can take in more than one option using getopt. But for some reason, even when i type in a covered option, it skips directly to my error message of "no match." Any ideas of what might be wrong?
set - 'getopt frd*: $*'
for i in $*
do... (6 Replies)
Hello ,
How to resolve below compilation error.activity_type is a member of structure and the output from databse will be stored in structure.Expected output wil l be either D or N or C .
sample struct format:
struct a{
char acAtivity_type;
}
code:
switch (a->activity_type)... (1 Reply)
I am just learning Tcl and there are few things about it that is perplexing me. I have a question about the switch statement.
Why are these two switch statements giving me different results?
$ cat test_switch.tcl
#!/usr/bin/tcl
set foo "abc"
switch abc a - b {puts "No. 1"} $foo {puts... (2 Replies)
Hey ,
I'm trying to perform the following command, however it cannot read the variable assigned earlier. I'm not sure why this happen. Please help thanks
while :
do
echo "what's ur name? (if none just press )"
read name
changeName = echo $name | sed "s/on/ey/"
echo $changeName #this... (8 Replies)
I started writing a script to save the files from a camera I got the other day, which mounts in /Volumes , and I got into it and started building this menu. The only problem is that the switch case is coming up as a syntax error at the parenthesis after a case. Here is the code:
while :
do
... (2 Replies)
Hello
i have a requirement where in a file i will get string. The length could be from 1 to 20. if the string is less than 6 characters ( ex: ABCD) . i need to append 'X' on right hand side to make it 6 characters (ex: ABCDXX). if suppose i get the same string from the file as ABCDXX then i... (5 Replies)
Hi
Am pretty new to C..
Am trying to pass the arguments from command line and use them in switch case statement..
i have tried the following
#include <stdlib.h>
main(int argc, char* argv)
{
int num=0;
if ( argc == 2 )
num = argv;
printf("%d is the num value",num);
switch ( num )
... (2 Replies)
I need to implement a looping logic.
If then
Go to /path1/file*
Get all the filename starting with file* and store it in a array
count file number and store it in variable like run
Ex: I found 3 file with starting file* so my run = 3
means my loop should run three time
May be... (1 Reply)
Discussion started by: Nsharma3006
1 Replies
LEARN ABOUT PHP
expect_expectl
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 seenSYNOPSIS
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)