How to send file from windows to UNIX daily?

Hi All!

I am trying to write a little script that should go to a windows server get one file and put on a unix server, but I am not sure if it is the right way please help:

#! /usr/bin/sh
HOST=10.100.48.41
USER=ftp_hm
PASSWD=P@$$w0rd

ftp -n $HOST
quote user $USER
quote pass $PASSWD
mget Shipment.csv
bye
END_SCRIPT
exit 0

See /t/automate-ftp-scripting-ftp-transfers/148989/1

If file is on a CIFS share eg pcshare on windows host pchost you can fetch it from the unix side:

smbclient -U pcuser%pcuserPASS //pchost/pcshare -c "get Shipment.csv"

Hi

Thank you for your inputs, but it seems that most of your examples are mainly to put files, but what I want is really a script running on unix that will go to a windows 2008 get a file

---------- Post updated at 10:04 AM ---------- Previous update was at 10:01 AM ----------

@Chubler_XL

I am not used to

smbclient

, but when I try

 smbclient -L 10.100.48.41
params.c:OpenConfFile() - Unable to open configuration file "/etc/samba/smb.conf":
        No such file or directory
smbclient: Can't load /etc/samba/smb.conf - run testparm to debug it

I think an empty /etc/samba/smb.conf file is all you need here.

Ok, I will create that, but I want to explore both set of options... can I have some also on the script running on the unix to go and fetch a

*.csv

on a windows directory.

You really can't imagine replacing the put command with get command? OK, instead of this...

#! /usr/bin/ksh

HOST=remote.host.name
USER=whoever
PASSWD=whatever

exec 4>&1
ftp -nv >&4 2>&4 |&

print -p open $HOST
print -p user $USER $PASSWD
print -p cd directory
print -p binary
print -p put tar.gz
print -p bye

wait
exit 0

you would need this...

#! /usr/bin/ksh

HOST=remote.host.name
USER=whoever
PASSWD=whatever

exec 4>&1
ftp -nv >&4 2>&4 |&

print -p open $HOST
print -p user $USER $PASSWD
print -p cd directory
print -p binary
print -p get tar.gz
print -p bye

wait
exit 0

Now I realize that your file may not be named tar.gz and your system may not be named remote.host.name. But try to use a little imagination here and adapt the example to your specific needs.

1 Like

thank you, I did use the

get

and it worked fine, after I actually posted my last comment.