Copy file from Windows to Linux WHEN A SHELL SCRIPT IS EXECUTED
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Copy file from Windows to Linux WHEN A SHELL SCRIPT IS EXECUTED
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.
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
write the steps. I think you're saying.
1. Linux script is on Linux system in /tmp, when executed write same script to a windows partition directory whenever it is executed?
if you are in Linux and want to access a windows directory you need to get and use the Linux classification for that drive and folder absolute path then just add the code into the script that will place a copy of whatever file you want to put into it. if you are creating a new empty file then put the code in the script to create a new (empty) file, touch is a good app to use for this.
things to consider. Is the accessed via IP address, or on the same box, is the partition mounted prior to execution of script, if no, then add code to mount drive partition, or gain access to the partition/directory so access can be gained for further exploitation.
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. 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
Your post makes no sense. You say:
You have a shell script in /tmp (?? NOT a good place for a shell script, generally), that you wrote. But can't write one additional line to copy a file? And you then say that the shell-script you mentioned is **EMPTY BY DEFAULT***???? How do you execute an empty file, exactly?
Basic logic: if you want to copy a file from another machine, you have to connect to it. You don't say if this Windows system has a shared folder, is accessible via FTP/SSH/whatever, but get your connection method first. From there, basic logic continues. If it's a shared folder, you connect to it via smbclient, or mount it via cifs, and copy the file like you would any other file, since the Windows share is mounted on Linux as just another drive.
In addition to the other comments, don't think about operating systems (Linux, Windows), think about filesystems. As others have said, all you need to do is issue a command to copy a file from one filesystem to another, ensuring that both filesystems are accessible to the system that issues the command (the origin filesystem with at least read access, the destination filesystem with at least write access).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.