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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Samba - Using smbclient to copy a file onto a Windows Share 1

Status
Not open for further replies.

pfildes

Programmer
Jun 17, 2004
54
0
0
GB
Hi,

I am having difficulty tranferring a file from my UNIX server to a Windows Share using the Samba client - smbclient, from a UNIX SH script

When I execute the following command from the shell prompt, it works perfectly;
[blue]/opt/samba/bin/smbclient //MyWinServer/MyWinShare$ -I 10.85.0.89 -A /home/me/smbclient.cfg -d 2 -c "put UKAGLMN_012012_9.csv; exit;"[/blue]

However when I execute the following source code within my SH script, it just hangs

Code:
tmpSambaCommand="$smbclientEXE //${AXWINSERVER}/${AXWINSHARE} -I ${AXWINIP} -A ${AXSMBAUTH} -d 2 -c \"put ${tmpFileToCopy}; exit;\""
echo $tmpSambaCommand
$tmpSambaCommand;;

/opt/samba/bin/smbclient //MyWinServer/MyWinShare$ -I 10.85.0.89 -A /home/
me/smbclient.cfg -d 2 -c "put UKAGLMN_012012_9.csv; quit;"
added interface ip=10.200.2.125 bcast=10.200.2.255 nmask=255.255.255.0
Domain=[GLOBAL] OS=[Windows Server 2003 3790 Service Pack 2] Server=[Windows Ser
ver 2003 5.2]
put <filename>

Can anybody please advise what I'm doing wrong?

I am completely baffled now [sad]
 
I have amended the "-c" command entry to include a "lcd", such that

Code:
tmpSambaCommand="$smbclientEXE //${AXWINSERVER}/${AXWINSHARE} -I ${AXWINIP} -A ${AXSMBAUTH} -d 2 -c \"lcd; put ${tmpFileToCopy}; exit;\""
echo $tmpSambaCommand
$tmpSambaCommand;;

This had the following affect;

/opt/samba/bin/smbclient //MyWinServer/MyWinShare$ -I 10.85.0.89 -A /home/
me/smbclient.cfg -d 2 -c "lcd; put UKAGLMN_012012_9.csv; exit;"
added interface ip=10.200.2.125 bcast=10.200.2.255 nmask=255.255.255.0
Domain=[GLOBAL] OS=[Windows Server 2003 3790 Service Pack 2] Server=[Windows Ser
ver 2003 5.2]
the local directory is now /opt/blah/blah/blah

It still hangs.
 
Try changing the last line to:

Code:
eval $tmpSambaCommand

I couldn't reproduce the hang, but when I tried it without doing the above the file was never transferred. The problem seems to be that it is passing the quotes around the list of commands to smbclient, which doesn't know how to deal with them. Let's see whether it resolves your hang too...



Annihilannic
[small]tgmlify - code syntax highlighting for your tek-tips posts[/small]
 
Thanks Annihilannic, adding the "eval" command as per your suggestion has resolved my problem nicely. The file I was trying to PUT was copied successfully [thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top