LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 10-07-2013, 05:19 AM   #1
_mz
Member
 
Registered: Jul 2013
Posts: 33

Rep: Reputation: Disabled
newbie in expect script


Hi Guys,

I have the following expect script:

#!/usr/bin/expect
set timeout -1

set remote_server "sgb\brian@192.168.200.5"
spawn /usr/bin/ftp $remote_server
expect "Password:"
send "passw0rd\n"
expect "ftp>"
send "lcd /usr/data\n"
expect "ftp>"
send "get transport_number.txt\n"
expect "ftp>"
send "exit\n"
interact

output:
spawn /usr/bin/ftp sgrian@192.168.200.5
Connected to 192.168.200.5.
220 Microsoft FTP Service
331 Password required for sgrian.
Password:
530 User sgrian cannot log in.
ftp: Login failed.
ftp> lcd /usr/data
Local directory now /usr/data
ftp> get transport_number.txt
local: transport_number.txt remote: transport_number.txt
500 'EPSV': command not understood
530 Please login with USER and PASS.
200 PORT command successful.
530 Please login with USER and PASS.
ftp> exit
221

The script fails due to it reads username "sgb\brian" as "sgrian" and leaves "b\b". If username does not have domain (just "brian") the script will success. How to make it successful?

TQ
 
Old 10-07-2013, 05:33 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
probably you would need to escape backslash (that means doubled backslashes: sgb\\brian)

Last edited by pan64; 10-07-2013 at 05:33 AM. Reason: typo
 
1 members found this post helpful.
Old 10-07-2013, 05:40 AM   #3
_mz
Member
 
Registered: Jul 2013
Posts: 33

Original Poster
Rep: Reputation: Disabled
@pan64,

TQVM, I do not think of it
 
  


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
Expect script: how do i send function key F12 in an expect script alix123 Programming 4 09-01-2013 10:06 PM
[root@fugo trace]# sh expect.sh expect.sh: line 9: expect: command not found sivaloga Linux - Kernel 1 08-22-2013 05:29 AM
[SOLVED] /usr/bin/expect : Script to check server load using both expect and bash Soji Antony Programming 1 07-28-2010 12:27 AM


All times are GMT -5. The time now is 10:22 AM.

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