Sponsored Content
Top Forums Shell Programming and Scripting want to use output of c programme in expect Post 302121370 by xander on Wednesday 13th of June 2007 12:36:47 PM
Old 06-13-2007
want to use output of c programme in expect

hi
i am having a c code which gives the output of my password in text format

i.e when i run my c code which which gives the password asfollows====>>>>>>
$./passwdprogram ======>>>>>>abc@123(this is the output)


now i have an expect script to remotely ssh which uses the password set in programme and works fine
if given in clear text format as follows
==========================================
#!/usr/bin/expect -f

set argu [lindex $argv 0]
set argg [lindex $argv 1]
set password "abc@123" ================here i want to change


spawn ssh user@<ip adress > sh portalhits $argu $argg
expect "^password:"
send "$password\r"
interact
==========================================
I want to use this in the following way

#!/usr/bin/expect -f

set argu [lindex $argv 0]
set argg [lindex $argv 1]
set password "./passwordprogramme" (in c) ================here i want to change


spawn ssh user@<ip adress> sh portalhits $argu $argg
expect "^password:"
send "$password\r"
interact
============================
so i want to figure that is there any way by which i can set the variable password with the output of the c code(./passwordprogramme) programme

can we do this by system() command .


Thanx Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get the output from EXPECT ?

I'm using expect script, but don't know how to assign an output to a string variable. Any help ? Thank you for reading! PS: In fact i want to get the out put of expect when run grub-md5-crypt to generate MD5 password for GRUB boot loader. My code:#!/bin/sh #\ exec expect -f "$0" ${1+"$@"}... (4 Replies)
Discussion started by: fongthai
4 Replies

2. Shell Programming and Scripting

Expect - Interact output hangs when large output

Hello, I have a simple expect script I use to ssh to a workstation. I then pass control over to the user with interact. This script works fine on my HP and Mac, but on my Linux Desktop, I get a problem where the terminal hangs when ever I execute a command in the interact session that requires a... (0 Replies)
Discussion started by: natedog
0 Replies

3. UNIX for Dummies Questions & Answers

how to save the output of command in tcl/expect

hi, everyone: I just wonder how to save the output of command, I mean everything, save as a string into a variable. another question is I try to ls the details of a directory, but it works in the shell, not in the script. for example code: ls -ltr *se100* | grep ^- | tail -1 | awk '... (1 Reply)
Discussion started by: allenxiao7
1 Replies

4. Shell Programming and Scripting

How can I scroll the terminal output with Expect

Hi, I'm trying to come up with a simple expect script that allows me to login to a system and run a single command ... something like this: #!/usr/bin/expect -f # let's set some variables #set password set ipaddr set ponumber set hostname set timeout -1 # let's now connect to the... (0 Replies)
Discussion started by: danielsf
0 Replies

5. Shell Programming and Scripting

Expect debug output

Hi! I want to start OO in headless mode via expect - the oo command would be su - root -c "/usr/lib/openoffice/program/soffice -headless -nofirststartwizard -norestore -nolockcheck -nocrashreport -nodefault -accept='socket,host=0.0.0.0,port=8100;urp;StarOffice.Service'" and the expect... (2 Replies)
Discussion started by: senior.weber
2 Replies

6. Shell Programming and Scripting

Expect doesn't output the logs

(qemu) migrate -d tcp:192.168.122.1:4444 (qemu) info migrate capabilities: xbzrle: off Migration status: completed total time: 4425 milliseconds downtime: 3 milliseconds transferred ram: 130338 kbytes remaining ram: 0 kbytes total ram: 1057152 kbytes duplicate: 232613 pages normal:... (0 Replies)
Discussion started by: yanglei_fage
0 Replies

7. Shell Programming and Scripting

Help capturing output of expect script

match_max 500000 set timeout 30 set outcome1 {} set outcome2 {} set inputfile C:\\Users\\Administrator\\Desktop\\inputfile.txt send -i $con "\r"; expect -i $con "Desktop>" { exp_send "type $inputfile \r" } set timeout 30 expect { "Desktop>" { set outcome $expect_out(0,string);}... (3 Replies)
Discussion started by: cityprince143
3 Replies

8. Shell Programming and Scripting

How do I use grep output in an expect script?

Hi, I am using expect to ssh to a remote host and run a program on the remote machine which has a variable runtime. I need to wait until it finishes so I can grab the output file of this program. I am trying to use the output of grep to know when the process finishes. I am trying to capture... (0 Replies)
Discussion started by: vagabond1964
0 Replies

9. Shell Programming and Scripting

Expect Script - Not Seeing Output from While Loop

I know something simple is missing here, "log_user 1" is set . . . after this utility opens ${InFile} (handle? for IntInFile) it needs to look for something to appear in the file ${IntInFile} and then send it to the spawned process. Then I am locking the file ${IntInFile} and clearing it out -... (0 Replies)
Discussion started by: JuanMatteo
0 Replies

10. Shell Programming and Scripting

Capture output from expect script

Hi I am new to Expect scripting. I have to connect to a remote server and capture the output. Here I need output of " send "list registered\r"" to be stored in a file. but after execution, /tmp/capture.txt is of 0 byte #!/usr/bin/expect spawn ssh abc@10.10.10.10 -p 5022 expect... (2 Replies)
Discussion started by: bns928
2 Replies
lindex(n)						       Tcl Built-In Commands							 lindex(n)

__________________________________________________________________________________________________________________________________________________

NAME
lindex - Retrieve an element from a list SYNOPSIS
lindex list ?index...? _________________________________________________________________ DESCRIPTION
The lindex command accepts a parameter, list, which it treats as a Tcl list. It also accepts zero or more indices into the list. The | indices may be presented either consecutively on the command line, or grouped in a Tcl list and presented as a single argument. | If no indices are presented, the command takes the form: | lindex list | or | lindex list {} | In this case, the return value of lindex is simply the value of the list parameter. | When presented with a single index, the lindex command treats list as a Tcl list and returns the index'th element from it (0 refers to the first element of the list). In extracting the element, lindex observes the same rules concerning braces and quotes and backslashes as the Tcl command interpreter; however, variable substitution and command substitution do not occur. If index is negative or greater than or equal to the number of elements in value, then an empty string is returned. If index has the value end, it refers to the last element in the list, and end-integer refers to the last element in the list minus the specified integer offset. If additional index arguments are supplied, then each argument is used in turn to select an element from the previous indexing operation, | allowing the script to select elements from sublists. The command, | lindex $a 1 2 3 | or | lindex $a {1 2 3} | is synonymous with | lindex [lindex [lindex $a 1] 2] 3 | EXAMPLES
| lindex {a b c} => a b c | lindex {a b c} {} => a b c | lindex {a b c} 0 => a | lindex {a b c} 2 => c | lindex {a b c} end => c | lindex {a b c} end-1 => b | lindex {{a b c} {d e f} {g h i}} 2 1 => h | lindex {{a b c} {d e f} {g h i}} {2 1} => h | lindex {{{a b} {c d}} {{e f} {g h}}} 1 1 0 => g | lindex {{{a b} {c d}} {{e f} {g h}}} {1 1 0} => g | SEE ALSO
list(n), lappend(n), linsert(n), llength(n), lsearch(n), lset(n), lsort(n), lrange(n), lreplace(n) | KEYWORDS
element, index, list Tcl 8.4 lindex(n)
All times are GMT -4. The time now is 02:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy