LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-17-2009, 08:20 AM   #1
ndnd
LQ Newbie
 
Registered: Sep 2009
Posts: 2

Rep: Reputation: 0
Unhappy combine bash & expect with variable from user input


hi all

I've tried to combine bash script and expect without any success...
can someone point me what is wrong here ?

#!/bin/bash
rm -rf /tmp/*log*
expect -c "
spawn /usr/bin/ssh -l username [lindex $argv 0]\n
expect )?
send yes\n
expect password:
send password\n
expect "Server"
send "print os date\n"
expect "is"
send "print os time\n"
"
sed -i 's/\r$//g' log
cat /tmp/log
exit
------------
here's the output i get when i run :
#./myscript 10.10.10.1 > log

without redirect to log file it look like this :
spawn /usr/bin/ssh -l username 0

The authenticity of host '0
(0.0.0.0)' can't be established.
RSA key fingerprint is 2c:6e:2a:d6:d0:43:73:06:95:be:82:8e:83:1d:a1:cf.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '0
' (RSA) to the list of known hosts.
username@0
's password:
Permission denied, please try again.


10x.
 
Old 09-17-2009, 08:25 AM   #2
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Nagpur, India
Distribution: Cent OS 5/6, Ubuntu Server 10.04
Posts: 4,629

Rep: Reputation: Disabled
Is not 0.0.0.0 a strange address and it will mean all the addresses available?
 
Old 09-17-2009, 10:18 AM   #3
ndnd
LQ Newbie
 
Registered: Sep 2009
Posts: 2

Original Poster
Rep: Reputation: 0
if i'm using only expect script , it works just fine :

#!/usr/bin/expect
spawn /usr/bin/ssh -l username [lindex $argv 0]\n
expect )?
send yes\n
expect password:
send password\n
expect "Server"
send "print os date\n"
expect "is"
send "print os time\n"
"
sed -i 's/\r$//g' log
cat /tmp/log
exit

but i need to run some other commands that's why I want to include bash inside and i don't wanna use multiple script files for that.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
User input into Bash scripts and checking validity of user input?? helptonewbie Programming 8 07-07-2008 07:40 PM
Unexpected curly braces in expect script spawn command & bash suid problem slinx Programming 1 05-02-2008 02:47 PM
Bash Y/N user input zcrxsir88 Programming 11 04-16-2008 12:35 PM
How to combine Expect and Shell script Uday123 Programming 0 12-27-2005 10:01 AM
bash - how to take input as a variable? trees Linux - General 1 02-19-2004 05:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration