LinuxQuestions.org
Visit Jeremy's Blog.
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, 04:19 AM   #1
_mz
Member
 
Registered: Jul 2013
Posts: 37

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, 04:33 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,775

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

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

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 09:06 PM
[root@fugo trace]# sh expect.sh expect.sh: line 9: expect: command not found sivaloga Linux - Kernel 1 08-22-2013 04:29 AM
[SOLVED] /usr/bin/expect : Script to check server load using both expect and bash Soji Antony Programming 1 07-27-2010 11:27 PM

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

All times are GMT -5. The time now is 12:51 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
Open Source Consulting | Domain Registration