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
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.
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.
Summary: Hi does anyone know how to pass a filename to vi?? what i mean is, i have some script that calls various different files based on user selection. and i want the user to be able edit these files in vi ...
Summary: Hello - I'm trying to write an expect script to first su to another user adn then run the passwd command. I created it by using autoexpect and then modified it to take command line parameters. The p...
Summary: Is it possible to pass a Unix environment variable to sed? The example script I have included shows what I am trying to do and the header explains why. I am running this script on Solaris KSh. #######...