Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

smbclient Question

Status
Not open for further replies.

tbohon

Programmer
Apr 20, 2000
293
US
I do a lot of ftp coding but am now faced with learning samba/smbclient since our new Win servers won't have ftp running on them. My source system (the one from which I'm trying to connect) is an AIX v5 box.

What I need to do is connect to a Win server using the smbclient version of the way I did it under ftp:

Code:
ftp -n <server IP> << EOF
user <username> <password>
cd <new directory.
put <file>
...
quit
EOF

I see in the man page for smbclient that I can use -c followed by a list of commands separated by semicolons and I suppose that would work it that's the only way - however, before I get that far I need to get the password to the smbclient and that's where I'm having problems right this minute. Latest version of my attempt:

Code:
smbclient \\<service> -U <username> <password>

Fails miserably.

Note that I also tried putting the <password> on a line under the smbclient call - basically replicating the ftp process above - also without success.

Until I can get some better docs on smbclient, does anyone have a quick way to replicate the ftp approach detailed above?

Tnx.

Tom

"My mind is like a steel whatchamacallit ...
 
-N -U 'username%password'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks, PH - I was just logging back on to tell everyone that I'd figured that piece out.

Still looking for options to the

Code:
-c "a;b;c;quit"

thing, however. Not critical - I'm able to connect with the fix above so I can live with a single long (really long) line of args if I have to.

Thanks!

Tom

"My mind is like a steel whatchamacallit ...
 
This works from a unix system to Win32. u1.txt contains a list of files piped to cpio.


cat /u1.txt | cpio -ocavB | smbclient //192.168.101.201/windir -U userid%password -c 'put - u1files.cpio;q'

 
Have you considered smbmount?
You could cross mount the file system and just copy files to and fro whenever you need to.


Trojan.
 
For me, smbmount is only available with a Linux kernel ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks for the additional information. I'm not able to smbmount so unfortunately that won't work. I'll definitely try the file with file names provided that I can get the file name pattern.

In testing today (I was able to have my script connect and bring the test file over!) I was a bit confused when it asked me 'yes or no' on getting the file. Obviously there has to be a trick to feeding it a 'y' answer automagically ... right???

Here's the smbclient call:

Code:
smbclient <service> -U <user>%<password> -c "cd data\temp;mget *.rtf;quit"

What I need to be able to do is feed it a 'y' answer after it tries to mget each file (I'll have the file pattern that I'll actually be looking for, in this case there was only the test file so I was lazy).

Thoughts?

Tnx.

Tom

"My mind is like a steel whatchamacallit ...
 
Think I figured it out. If I use prompt inside the command string right before the mget - just like I do in ftp scripts - it won't prompt me.

Thanks all!

Best,

Tom

"My mind is like a steel whatchamacallit ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top