I need to execute a datastage ETL job which runs a shell script to move files from a specific folder in windows machine (not a file system) to a directory in unix.

I have something like this now

ftp -v -n WINDOWS123 << end_script
user zxc/VKR XYZ
lcd /stg/scripts 
cd "data" 
mget *.txt

The mget command here just copies the files. I would want to move the files instead of a copy

  • 2
    By, "to a folder in unix" you mean a folder on another partition? – Erik Jul 19 '17 at 13:35
  • 2
    Do you mean a remote Windows machine, or do you mean some Windows file-system (e.g. NTFS) mounted on Linux? Please edit your question to improve it a lot (currently it is unclear). BTW, Unix systems have directories (not folders, which are just a GUI artefact). And what is a "datastage" job? – Basile Starynkevitch Jul 19 '17 at 13:39
  • you state two machines. 1 windows 1 linux. how they are related? is the nix machine running samba? is the windows running FTP/SFTP service? will the windows machine deliver to unix the files via FTP/SFTP? plz share more details on what exactly the relation will be between the servers? – GiannakopoulosJ Jul 19 '17 at 13:44
  • And your question is... ? – dr01 Jul 19 '17 at 14:47
  • Can we assume that the listed user has Windows permissions to delete the files? – Jeff Schaller Jul 19 '17 at 16:12

If you have a windows box with at least an admin share \\computer\c$ and you have a linux box that will run the script:

Mount the windows share read/write

mount -t cifs $network_path $mount_directory -o credentials=$cred_file

Execute the move command on the mounted directory

mv "$mount_directory/*" "$new_directory"

May need to copy then delete the files...

cp "$mount_directory/*"
rm "$mount_directory/*"

Check the switches you may require on the commands (cp, mv and rm).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.