Copy file from Windows to Linux, when a shell script is executed

-1

I have a program on Linux server, which runs a shell script on Linux server. Say /tmp/ShellScript.sh

Now I want to copy a file placed on my Windows Machine location C:\WindowsFolder\FileToCopy to Linux System directory /tmp, only whenever /tmp/ShellScript.sh is executed on Linux by the program.

How can I achieve this?

I can also manipulate the script /tmp/ShellScript.sh itself and write the logic in that, considering it is empty by default.

Rahul

Posted 2018-08-27T12:21:33.187

Reputation: 9

3Ok. What have you tried already? What kind of problem are you having? Where is the script you’re currently working with? This question shows a lack of research and effort. – Appleoddity – 2018-08-27T12:39:13.463

1There are very many ways to achieve this, depending on your setup. Are they on the same LAN? Is the folder with the file shared via LAN? Do you want want access over WAN? You should think about all your requirements and mention them in the question, before somebody uses their time to write a solution that does not fit with your requirements. And also it helps if you actually have tried to do it yourself before you ask, so you have a better grip of your needs and can tell why X does not work etc. Just a tip that can help people help you easier – anders – 2018-08-27T12:39:16.693

Answers

0

First create shared folder from the Windows machine - [c:\windowsfolder]1 -

Second mount the windows shared folder to your linux machine -

mount -t cifs -o username=<share user>,password=<share password> //WIN_PC_IP/<share name> /mnt/winfolder

Run your linux shell script to copy from /mnt/winfolder (or other folder you want) to /tmp

JuniorPenguin

Posted 2018-08-27T12:21:33.187

Reputation: 21