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
shell-script filenames
add a comment |
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
shell-script filenames
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 usecp -i /path/to/sourcefile /path/to/copiedfile
or useSystem.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
add a comment |
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
shell-script filenames
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
shell-script filenames
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 usecp -i /path/to/sourcefile /path/to/copiedfile
or useSystem.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
add a comment |
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 usecp -i /path/to/sourcefile /path/to/copiedfile
or useSystem.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
add a comment |
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.
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
|
show 2 more comments
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.
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
|
show 2 more comments
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.
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
|
show 2 more comments
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.
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.
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
|
show 2 more comments
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
|
show 2 more comments
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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 useSystem.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