Computing.Net > Forums > Unix > Passing '\' in username to expect

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Passing '\' in username to expect

Reply to Message Icon

Name: checkpro
Date: December 29, 2008 at 14:01:33 Pacific
OS: Unix
CPU/Ram: Xeon -- 4GB
Product: Hewlett-packard / PROLIANT ML370G5
Comment:

I'm writing an expect script to use sftp to download a file from a secure server. Actually, I'm modifying one of my existing scripts which does the same thing. I'm already doing this with several other scripts for different customers. However, this clearing house has issued a username with a back slash in he middle of it. I can manually sftp to the site using:
sftp user\\name@sftp.server.com, (note the TWO back slashes, it doesn't work otherwise. The back slash has to be escaped.) When I pass the username parameter via a variable, $uname, I lose the back slash. I'd rather not hard-code anything into the expect script if I can help it. I've emailed the tech support folks to see if I can get a username without the back slash, but in the mean time I'm searching for a way to do it WITH the back slash. Any help would be greatly appreciated.



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: December 29, 2008 at 23:12:03 Pacific
Reply:

Probably what is happening, is that spawning a shell "eats" one of the slashes. Try adding another slash, and, of course, you have to escape it:

var1="user\\\\name@sftp.server.com"


0

Response Number 2
Name: checkpro
Date: December 30, 2008 at 09:14:26 Pacific
Reply:

I had already tried a third \ but not a fourth. I did figure out the problem though. The problem was a loose nut between the keyboard and the chair. The real issue was this:
I send user\\name@sftp.server.com, the response is:
user\name@sftp.server.com's password:
but I was telling expect to look for:
user\\name@sftp.server.com's password:
Note the server is responding to the correct username, but I'm telling expect to look for formatted username. Anyway, thanks for the response.


0

Response Number 3
Name: checkpro
Date: December 31, 2008 at 10:49:26 Pacific
Reply:

I had already tried a third \ but not a fourth. I did figure out the problem though. The problem was a loose nut between the keyboard and the chair. The real issue was this:
I send user\\name@sftp.server.com, the response is:
user\name@sftp.server.com's password:
but I was telling expect to look for:
user\\name@sftp.server.com's password:
Note the server is responding to the correct username, but I'm telling expect to look for formatted username. Anyway, thanks for the response.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Passing '\' in username to expect

passing a filename to vi ?? www.computing.net/answers/unix/passing-a-filename-to-vi-/5813.html

Expect script to su and run passwd www.computing.net/answers/unix/expect-script-to-su-and-run-passwd/6154.html

Pass environment variables to sed www.computing.net/answers/unix/pass-environment-variables-to-sed/7387.html