Sponsored Content
Full Discussion: Expect Question
Top Forums UNIX for Beginners Questions & Answers Expect Question Post 303030142 by jimmyf on Wednesday 6th of February 2019 12:48:10 PM
Old 02-06-2019
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.


Code:
#!/bin/bash
cd /root
cat /root/hostname1.txt | while read line
do
   expect -c "
log_user 1
spawn ssh -o UserKnownHostsFile=/dev/null -o strictHostKeyChecking=no user@$line
expect \"word:\"
send \"password\r\"
expect \"# \"
send \"whoami\r\"
expect \"# \"
send \"su -\r\"
expect \"word:\"
send \"password\r\"
expect \"# \"
send \"pwd\"
expect \"# \"
send \"!\r\"
" 

done

 

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

Expect question

Hi all, I have got a small expect script like this one. #!/usr/bin/expect -f set timeout 2 spawn ftp $env(IP) match_max 100000 expect -exact "Name" send -- "$env(USER)\n" expect -exact "Password:" send -- "$env(PASSWORD)\n" expect "%" send "bin\r" expect "%" send "prompt\r"... (5 Replies)
Discussion started by: stinkefisch
5 Replies

5. 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

6. 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

7. 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

8. 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

9. 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
PMDAELASTICSEARCH(1)					       Performance Co-Pilot					      PMDAELASTICSEARCH(1)

NAME
pmdaelasticsearch - elasticsearch performance metrics domain agent (PMDA) DESCRIPTION
pmdaelasticsearch is a Performance Metrics Domain Agent (PMDA) which exports metric values from elasticsearch. INSTALLATION
This PMDA requires that elasticsearch is running on the local host and is accepting queries on TCP port 9200 Install the elasticsearch PMDA by using the Install script as root: # cd $PCP_PMDAS_DIR/elasticsearch # ./Install To uninstall, do the following as root: # cd $PCP_PMDAS_DIR/elasticsearch # ./Remove pmdaelasticsearch is launched by pmcd(1) and should never be executed directly. The Install and Remove scripts notify pmcd(1) when the agent is installed or removed. FILES
$PCP_PMDAS_DIR/elasticsearch/es.conf optional configuration file for pmdaelasticsearch elasticsearch PMDA for PCP $PCP_PMDAS_DIR/elasticsearch/Install installation script for the pmdaelasticsearch agent $PCP_PMDAS_DIR/elasticsearch/Remove undo installation script for the pmdaelasticsearch agent $PCP_LOG_DIR/pmcd/elasticsearch.log default log file for error messages from pmdaelasticsearch SEE ALSO
pmcd(1). 3.8.10 Performance Co-Pilot PMDAELASTICSEARCH(1)
All times are GMT -4. The time now is 09:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy