Shell Script to copy the file to another folder











up vote
-2
down vote

favorite












I have to write .sh file which will be called from .Net Application.



Script.sh has to move the file from rootdirectory to a specified folder.



I am expecting to pass SourceFilePath and DestinationFilePath as parameters for .sh file.



How to write a .sh file with parameters.



#vim script.sh
echo "hometestuserfile.csv"
read a
echo "homeadminuser2datafile.csv"
read b
echo "Data will be moving from $a to $b"
mv $a $b
echo "Moving done"

:wq

#chmod u+x script.sh
#./script.sh









share|improve this question




















  • 2




    Unix uses / as the directory separator in pathnames, not
    – Barmar
    Sep 16 '14 at 14:35








  • 1




    Why backslashes if this is on linux, or are those not directory separators?
    – Anthon
    Sep 16 '14 at 14:35










  • .Net and the Cygwin shell are not usable together. You must either login to Cygwin and use cp -i /path/to/sourcefile /path/to/copiedfile or use System.File.Copy to copy the File outside of Cygwin. This method is not advised as the encoding will be different. The fact that this is an SMB Share is moot.
    – eyoung100
    Sep 16 '14 at 14:40















up vote
-2
down vote

favorite












I have to write .sh file which will be called from .Net Application.



Script.sh has to move the file from rootdirectory to a specified folder.



I am expecting to pass SourceFilePath and DestinationFilePath as parameters for .sh file.



How to write a .sh file with parameters.



#vim script.sh
echo "hometestuserfile.csv"
read a
echo "homeadminuser2datafile.csv"
read b
echo "Data will be moving from $a to $b"
mv $a $b
echo "Moving done"

:wq

#chmod u+x script.sh
#./script.sh









share|improve this question




















  • 2




    Unix uses / as the directory separator in pathnames, not
    – Barmar
    Sep 16 '14 at 14:35








  • 1




    Why backslashes if this is on linux, or are those not directory separators?
    – Anthon
    Sep 16 '14 at 14:35










  • .Net and the Cygwin shell are not usable together. You must either login to Cygwin and use cp -i /path/to/sourcefile /path/to/copiedfile or use System.File.Copy to copy the File outside of Cygwin. This method is not advised as the encoding will be different. The fact that this is an SMB Share is moot.
    – eyoung100
    Sep 16 '14 at 14:40













up vote
-2
down vote

favorite









up vote
-2
down vote

favorite











I have to write .sh file which will be called from .Net Application.



Script.sh has to move the file from rootdirectory to a specified folder.



I am expecting to pass SourceFilePath and DestinationFilePath as parameters for .sh file.



How to write a .sh file with parameters.



#vim script.sh
echo "hometestuserfile.csv"
read a
echo "homeadminuser2datafile.csv"
read b
echo "Data will be moving from $a to $b"
mv $a $b
echo "Moving done"

:wq

#chmod u+x script.sh
#./script.sh









share|improve this question















I have to write .sh file which will be called from .Net Application.



Script.sh has to move the file from rootdirectory to a specified folder.



I am expecting to pass SourceFilePath and DestinationFilePath as parameters for .sh file.



How to write a .sh file with parameters.



#vim script.sh
echo "hometestuserfile.csv"
read a
echo "homeadminuser2datafile.csv"
read b
echo "Data will be moving from $a to $b"
mv $a $b
echo "Moving done"

:wq

#chmod u+x script.sh
#./script.sh






shell-script filenames






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 24 at 20:32









Rui F Ribeiro

38.3k1475126




38.3k1475126










asked Sep 16 '14 at 14:31









wasabi

611




611








  • 2




    Unix uses / as the directory separator in pathnames, not
    – Barmar
    Sep 16 '14 at 14:35








  • 1




    Why backslashes if this is on linux, or are those not directory separators?
    – Anthon
    Sep 16 '14 at 14:35










  • .Net and the Cygwin shell are not usable together. You must either login to Cygwin and use cp -i /path/to/sourcefile /path/to/copiedfile or use System.File.Copy to copy the File outside of Cygwin. This method is not advised as the encoding will be different. The fact that this is an SMB Share is moot.
    – eyoung100
    Sep 16 '14 at 14:40














  • 2




    Unix uses / as the directory separator in pathnames, not
    – Barmar
    Sep 16 '14 at 14:35








  • 1




    Why backslashes if this is on linux, or are those not directory separators?
    – Anthon
    Sep 16 '14 at 14:35










  • .Net and the Cygwin shell are not usable together. You must either login to Cygwin and use cp -i /path/to/sourcefile /path/to/copiedfile or use System.File.Copy to copy the File outside of Cygwin. This method is not advised as the encoding will be different. The fact that this is an SMB Share is moot.
    – eyoung100
    Sep 16 '14 at 14:40








2




2




Unix uses / as the directory separator in pathnames, not
– Barmar
Sep 16 '14 at 14:35






Unix uses / as the directory separator in pathnames, not
– Barmar
Sep 16 '14 at 14:35






1




1




Why backslashes if this is on linux, or are those not directory separators?
– Anthon
Sep 16 '14 at 14:35




Why backslashes if this is on linux, or are those not directory separators?
– Anthon
Sep 16 '14 at 14:35












.Net and the Cygwin shell are not usable together. You must either login to Cygwin and use cp -i /path/to/sourcefile /path/to/copiedfile or use System.File.Copy to copy the File outside of Cygwin. This method is not advised as the encoding will be different. The fact that this is an SMB Share is moot.
– eyoung100
Sep 16 '14 at 14:40




.Net and the Cygwin shell are not usable together. You must either login to Cygwin and use cp -i /path/to/sourcefile /path/to/copiedfile or use System.File.Copy to copy the File outside of Cygwin. This method is not advised as the encoding will be different. The fact that this is an SMB Share is moot.
– eyoung100
Sep 16 '14 at 14:40










1 Answer
1






active

oldest

votes

















up vote
0
down vote













All you need is



#!/usr/bin/env bash

echo "Data will be moving from $1 to $2."
mv -- "$1" "$2"


Save the script as foo.sh, make it executable (chmod 744 foo.sh) and run it giving the source and destination as arguments:



./foo.sh /home/testuser/file.csv /home/admin/user2/data/file.csv


I have no idea if this plays well with .Net but it will work as expected on a *nix platform.






share|improve this answer























  • See my comment above... He's trying to "cheat environments" .NET will not copy/move from a virtualized environment cleanly as he will have encoding Issues, UTF-8 TO ASCII etc.
    – eyoung100
    Sep 16 '14 at 14:47










  • @ECarterYoung I have less than no knowledge of .Net. I had ignored that part until seeing your comment at which point I added the disclaimer at the end of my answer. This answers the only part of the Q that is vaguely on topic though so...
    – terdon
    Sep 16 '14 at 14:50










  • I agree about the Q/A but by answering we opened the proverbial "can of worms."
    – eyoung100
    Sep 16 '14 at 15:01










  • @ECarterYoung indeed. I'm expecting this to be closed soon.
    – terdon
    Sep 16 '14 at 15:10










  • @ECarterYoung , there is something called respect. I am not here to cheat any Environment. I have mentioned very clearly, i am new to Linux. I might be wrong or i might be right. Let me give a try. Thanks for downvoting, That doesn't stop my effort
    – wasabi
    Sep 16 '14 at 15:10











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f155884%2fshell-script-to-copy-the-file-to-another-folder%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













All you need is



#!/usr/bin/env bash

echo "Data will be moving from $1 to $2."
mv -- "$1" "$2"


Save the script as foo.sh, make it executable (chmod 744 foo.sh) and run it giving the source and destination as arguments:



./foo.sh /home/testuser/file.csv /home/admin/user2/data/file.csv


I have no idea if this plays well with .Net but it will work as expected on a *nix platform.






share|improve this answer























  • See my comment above... He's trying to "cheat environments" .NET will not copy/move from a virtualized environment cleanly as he will have encoding Issues, UTF-8 TO ASCII etc.
    – eyoung100
    Sep 16 '14 at 14:47










  • @ECarterYoung I have less than no knowledge of .Net. I had ignored that part until seeing your comment at which point I added the disclaimer at the end of my answer. This answers the only part of the Q that is vaguely on topic though so...
    – terdon
    Sep 16 '14 at 14:50










  • I agree about the Q/A but by answering we opened the proverbial "can of worms."
    – eyoung100
    Sep 16 '14 at 15:01










  • @ECarterYoung indeed. I'm expecting this to be closed soon.
    – terdon
    Sep 16 '14 at 15:10










  • @ECarterYoung , there is something called respect. I am not here to cheat any Environment. I have mentioned very clearly, i am new to Linux. I might be wrong or i might be right. Let me give a try. Thanks for downvoting, That doesn't stop my effort
    – wasabi
    Sep 16 '14 at 15:10















up vote
0
down vote













All you need is



#!/usr/bin/env bash

echo "Data will be moving from $1 to $2."
mv -- "$1" "$2"


Save the script as foo.sh, make it executable (chmod 744 foo.sh) and run it giving the source and destination as arguments:



./foo.sh /home/testuser/file.csv /home/admin/user2/data/file.csv


I have no idea if this plays well with .Net but it will work as expected on a *nix platform.






share|improve this answer























  • See my comment above... He's trying to "cheat environments" .NET will not copy/move from a virtualized environment cleanly as he will have encoding Issues, UTF-8 TO ASCII etc.
    – eyoung100
    Sep 16 '14 at 14:47










  • @ECarterYoung I have less than no knowledge of .Net. I had ignored that part until seeing your comment at which point I added the disclaimer at the end of my answer. This answers the only part of the Q that is vaguely on topic though so...
    – terdon
    Sep 16 '14 at 14:50










  • I agree about the Q/A but by answering we opened the proverbial "can of worms."
    – eyoung100
    Sep 16 '14 at 15:01










  • @ECarterYoung indeed. I'm expecting this to be closed soon.
    – terdon
    Sep 16 '14 at 15:10










  • @ECarterYoung , there is something called respect. I am not here to cheat any Environment. I have mentioned very clearly, i am new to Linux. I might be wrong or i might be right. Let me give a try. Thanks for downvoting, That doesn't stop my effort
    – wasabi
    Sep 16 '14 at 15:10













up vote
0
down vote










up vote
0
down vote









All you need is



#!/usr/bin/env bash

echo "Data will be moving from $1 to $2."
mv -- "$1" "$2"


Save the script as foo.sh, make it executable (chmod 744 foo.sh) and run it giving the source and destination as arguments:



./foo.sh /home/testuser/file.csv /home/admin/user2/data/file.csv


I have no idea if this plays well with .Net but it will work as expected on a *nix platform.






share|improve this answer














All you need is



#!/usr/bin/env bash

echo "Data will be moving from $1 to $2."
mv -- "$1" "$2"


Save the script as foo.sh, make it executable (chmod 744 foo.sh) and run it giving the source and destination as arguments:



./foo.sh /home/testuser/file.csv /home/admin/user2/data/file.csv


I have no idea if this plays well with .Net but it will work as expected on a *nix platform.







share|improve this answer














share|improve this answer



share|improve this answer








edited Sep 16 '14 at 21:34









Gilles

522k12610401575




522k12610401575










answered Sep 16 '14 at 14:41









terdon

126k31243419




126k31243419












  • See my comment above... He's trying to "cheat environments" .NET will not copy/move from a virtualized environment cleanly as he will have encoding Issues, UTF-8 TO ASCII etc.
    – eyoung100
    Sep 16 '14 at 14:47










  • @ECarterYoung I have less than no knowledge of .Net. I had ignored that part until seeing your comment at which point I added the disclaimer at the end of my answer. This answers the only part of the Q that is vaguely on topic though so...
    – terdon
    Sep 16 '14 at 14:50










  • I agree about the Q/A but by answering we opened the proverbial "can of worms."
    – eyoung100
    Sep 16 '14 at 15:01










  • @ECarterYoung indeed. I'm expecting this to be closed soon.
    – terdon
    Sep 16 '14 at 15:10










  • @ECarterYoung , there is something called respect. I am not here to cheat any Environment. I have mentioned very clearly, i am new to Linux. I might be wrong or i might be right. Let me give a try. Thanks for downvoting, That doesn't stop my effort
    – wasabi
    Sep 16 '14 at 15:10


















  • See my comment above... He's trying to "cheat environments" .NET will not copy/move from a virtualized environment cleanly as he will have encoding Issues, UTF-8 TO ASCII etc.
    – eyoung100
    Sep 16 '14 at 14:47










  • @ECarterYoung I have less than no knowledge of .Net. I had ignored that part until seeing your comment at which point I added the disclaimer at the end of my answer. This answers the only part of the Q that is vaguely on topic though so...
    – terdon
    Sep 16 '14 at 14:50










  • I agree about the Q/A but by answering we opened the proverbial "can of worms."
    – eyoung100
    Sep 16 '14 at 15:01










  • @ECarterYoung indeed. I'm expecting this to be closed soon.
    – terdon
    Sep 16 '14 at 15:10










  • @ECarterYoung , there is something called respect. I am not here to cheat any Environment. I have mentioned very clearly, i am new to Linux. I might be wrong or i might be right. Let me give a try. Thanks for downvoting, That doesn't stop my effort
    – wasabi
    Sep 16 '14 at 15:10
















See my comment above... He's trying to "cheat environments" .NET will not copy/move from a virtualized environment cleanly as he will have encoding Issues, UTF-8 TO ASCII etc.
– eyoung100
Sep 16 '14 at 14:47




See my comment above... He's trying to "cheat environments" .NET will not copy/move from a virtualized environment cleanly as he will have encoding Issues, UTF-8 TO ASCII etc.
– eyoung100
Sep 16 '14 at 14:47












@ECarterYoung I have less than no knowledge of .Net. I had ignored that part until seeing your comment at which point I added the disclaimer at the end of my answer. This answers the only part of the Q that is vaguely on topic though so...
– terdon
Sep 16 '14 at 14:50




@ECarterYoung I have less than no knowledge of .Net. I had ignored that part until seeing your comment at which point I added the disclaimer at the end of my answer. This answers the only part of the Q that is vaguely on topic though so...
– terdon
Sep 16 '14 at 14:50












I agree about the Q/A but by answering we opened the proverbial "can of worms."
– eyoung100
Sep 16 '14 at 15:01




I agree about the Q/A but by answering we opened the proverbial "can of worms."
– eyoung100
Sep 16 '14 at 15:01












@ECarterYoung indeed. I'm expecting this to be closed soon.
– terdon
Sep 16 '14 at 15:10




@ECarterYoung indeed. I'm expecting this to be closed soon.
– terdon
Sep 16 '14 at 15:10












@ECarterYoung , there is something called respect. I am not here to cheat any Environment. I have mentioned very clearly, i am new to Linux. I might be wrong or i might be right. Let me give a try. Thanks for downvoting, That doesn't stop my effort
– wasabi
Sep 16 '14 at 15:10




@ECarterYoung , there is something called respect. I am not here to cheat any Environment. I have mentioned very clearly, i am new to Linux. I might be wrong or i might be right. Let me give a try. Thanks for downvoting, That doesn't stop my effort
– wasabi
Sep 16 '14 at 15:10


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f155884%2fshell-script-to-copy-the-file-to-another-folder%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

サソリ

広島県道265号伴広島線

Accessing regular linux commands in Huawei's Dopra Linux