wget and scp as a pipeline
up vote
0
down vote
favorite
Can we use wget and scp as a pipeline. I want to wget a file from a server and copy to another server. I used below command but it is not working.
wget "$Select_Release_Version_ARTIFACT_URL" | sudo scp test@192.168.94.137:/etc/test/
linux shell pipe wget scp
add a comment |
up vote
0
down vote
favorite
Can we use wget and scp as a pipeline. I want to wget a file from a server and copy to another server. I used below command but it is not working.
wget "$Select_Release_Version_ARTIFACT_URL" | sudo scp test@192.168.94.137:/etc/test/
linux shell pipe wget scp
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Can we use wget and scp as a pipeline. I want to wget a file from a server and copy to another server. I used below command but it is not working.
wget "$Select_Release_Version_ARTIFACT_URL" | sudo scp test@192.168.94.137:/etc/test/
linux shell pipe wget scp
Can we use wget and scp as a pipeline. I want to wget a file from a server and copy to another server. I used below command but it is not working.
wget "$Select_Release_Version_ARTIFACT_URL" | sudo scp test@192.168.94.137:/etc/test/
linux shell pipe wget scp
linux shell pipe wget scp
edited Nov 15 at 11:18
Jeff Schaller
36.1k952119
36.1k952119
asked Nov 15 at 5:25
Janith
52
52
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
To use wget
in a pipe, you must make sure it writes to stdout
instead to a file, so use wget -O- ...
.
AFAIK, you can't use scp
to copy from stdin
. However, you can use ssh
instead, and have it execute a command like cat
, which reads from stdin
.
So together you get something like
wget -O- "$Select_Release_Version_ARTIFACT_URL" | ssh test@192.168.94.137 'cat > /etc/test/some_file'
Note that will only download and transfer a single file/webpage. Also note that user test
on 192.168.94.137
needs rights to create and write to /etc/test/some_file
. Using sudo
before ssh
won't give the remote user test
any additional rights. It will allow to access ssh keys of root on the local machine, so if that was the intention, keep it.
While this demonstrates how to use a pipe over ssh
, it would have been easier to just execute wget
on the remote machine, unless there are reasons why this is not possible.
add a comment |
up vote
0
down vote
Instead of pipe, you can use &&
. This will make sure that when scp
runs if wget
has exit status of 0 (finished successfully).
wget "$Select_Release_Version_ARTIFACT_URL" && sudo scp "$Select_Release_Version_ARTIFACT_URL" test@192.168.94.137:/etc/test/
This works as following:
wget
downloads the file and IF SUCCESSFUL, it will initiate scp
.
NOTE: Since you are using sudo
, this will ask the password test
user every time this command will run.
I used passwordless authentication, I think no need of providing password.
– Janith
Nov 15 at 5:35
When I using above command I am getting error.wget
is working butscp
is not working.
– Janith
Nov 15 at 5:42
Note that if the named file already exists, wget will download intofilename.1
,filename.2
, etc.
– Ulrich Schwarz
Nov 15 at 5:52
Yes can I write a scrip to download and copy to remote machine same time?
– Janith
Nov 15 at 6:00
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
To use wget
in a pipe, you must make sure it writes to stdout
instead to a file, so use wget -O- ...
.
AFAIK, you can't use scp
to copy from stdin
. However, you can use ssh
instead, and have it execute a command like cat
, which reads from stdin
.
So together you get something like
wget -O- "$Select_Release_Version_ARTIFACT_URL" | ssh test@192.168.94.137 'cat > /etc/test/some_file'
Note that will only download and transfer a single file/webpage. Also note that user test
on 192.168.94.137
needs rights to create and write to /etc/test/some_file
. Using sudo
before ssh
won't give the remote user test
any additional rights. It will allow to access ssh keys of root on the local machine, so if that was the intention, keep it.
While this demonstrates how to use a pipe over ssh
, it would have been easier to just execute wget
on the remote machine, unless there are reasons why this is not possible.
add a comment |
up vote
1
down vote
To use wget
in a pipe, you must make sure it writes to stdout
instead to a file, so use wget -O- ...
.
AFAIK, you can't use scp
to copy from stdin
. However, you can use ssh
instead, and have it execute a command like cat
, which reads from stdin
.
So together you get something like
wget -O- "$Select_Release_Version_ARTIFACT_URL" | ssh test@192.168.94.137 'cat > /etc/test/some_file'
Note that will only download and transfer a single file/webpage. Also note that user test
on 192.168.94.137
needs rights to create and write to /etc/test/some_file
. Using sudo
before ssh
won't give the remote user test
any additional rights. It will allow to access ssh keys of root on the local machine, so if that was the intention, keep it.
While this demonstrates how to use a pipe over ssh
, it would have been easier to just execute wget
on the remote machine, unless there are reasons why this is not possible.
add a comment |
up vote
1
down vote
up vote
1
down vote
To use wget
in a pipe, you must make sure it writes to stdout
instead to a file, so use wget -O- ...
.
AFAIK, you can't use scp
to copy from stdin
. However, you can use ssh
instead, and have it execute a command like cat
, which reads from stdin
.
So together you get something like
wget -O- "$Select_Release_Version_ARTIFACT_URL" | ssh test@192.168.94.137 'cat > /etc/test/some_file'
Note that will only download and transfer a single file/webpage. Also note that user test
on 192.168.94.137
needs rights to create and write to /etc/test/some_file
. Using sudo
before ssh
won't give the remote user test
any additional rights. It will allow to access ssh keys of root on the local machine, so if that was the intention, keep it.
While this demonstrates how to use a pipe over ssh
, it would have been easier to just execute wget
on the remote machine, unless there are reasons why this is not possible.
To use wget
in a pipe, you must make sure it writes to stdout
instead to a file, so use wget -O- ...
.
AFAIK, you can't use scp
to copy from stdin
. However, you can use ssh
instead, and have it execute a command like cat
, which reads from stdin
.
So together you get something like
wget -O- "$Select_Release_Version_ARTIFACT_URL" | ssh test@192.168.94.137 'cat > /etc/test/some_file'
Note that will only download and transfer a single file/webpage. Also note that user test
on 192.168.94.137
needs rights to create and write to /etc/test/some_file
. Using sudo
before ssh
won't give the remote user test
any additional rights. It will allow to access ssh keys of root on the local machine, so if that was the intention, keep it.
While this demonstrates how to use a pipe over ssh
, it would have been easier to just execute wget
on the remote machine, unless there are reasons why this is not possible.
answered Nov 15 at 7:28
dirkt
16.1k21234
16.1k21234
add a comment |
add a comment |
up vote
0
down vote
Instead of pipe, you can use &&
. This will make sure that when scp
runs if wget
has exit status of 0 (finished successfully).
wget "$Select_Release_Version_ARTIFACT_URL" && sudo scp "$Select_Release_Version_ARTIFACT_URL" test@192.168.94.137:/etc/test/
This works as following:
wget
downloads the file and IF SUCCESSFUL, it will initiate scp
.
NOTE: Since you are using sudo
, this will ask the password test
user every time this command will run.
I used passwordless authentication, I think no need of providing password.
– Janith
Nov 15 at 5:35
When I using above command I am getting error.wget
is working butscp
is not working.
– Janith
Nov 15 at 5:42
Note that if the named file already exists, wget will download intofilename.1
,filename.2
, etc.
– Ulrich Schwarz
Nov 15 at 5:52
Yes can I write a scrip to download and copy to remote machine same time?
– Janith
Nov 15 at 6:00
add a comment |
up vote
0
down vote
Instead of pipe, you can use &&
. This will make sure that when scp
runs if wget
has exit status of 0 (finished successfully).
wget "$Select_Release_Version_ARTIFACT_URL" && sudo scp "$Select_Release_Version_ARTIFACT_URL" test@192.168.94.137:/etc/test/
This works as following:
wget
downloads the file and IF SUCCESSFUL, it will initiate scp
.
NOTE: Since you are using sudo
, this will ask the password test
user every time this command will run.
I used passwordless authentication, I think no need of providing password.
– Janith
Nov 15 at 5:35
When I using above command I am getting error.wget
is working butscp
is not working.
– Janith
Nov 15 at 5:42
Note that if the named file already exists, wget will download intofilename.1
,filename.2
, etc.
– Ulrich Schwarz
Nov 15 at 5:52
Yes can I write a scrip to download and copy to remote machine same time?
– Janith
Nov 15 at 6:00
add a comment |
up vote
0
down vote
up vote
0
down vote
Instead of pipe, you can use &&
. This will make sure that when scp
runs if wget
has exit status of 0 (finished successfully).
wget "$Select_Release_Version_ARTIFACT_URL" && sudo scp "$Select_Release_Version_ARTIFACT_URL" test@192.168.94.137:/etc/test/
This works as following:
wget
downloads the file and IF SUCCESSFUL, it will initiate scp
.
NOTE: Since you are using sudo
, this will ask the password test
user every time this command will run.
Instead of pipe, you can use &&
. This will make sure that when scp
runs if wget
has exit status of 0 (finished successfully).
wget "$Select_Release_Version_ARTIFACT_URL" && sudo scp "$Select_Release_Version_ARTIFACT_URL" test@192.168.94.137:/etc/test/
This works as following:
wget
downloads the file and IF SUCCESSFUL, it will initiate scp
.
NOTE: Since you are using sudo
, this will ask the password test
user every time this command will run.
answered Nov 15 at 5:31
sla3k
3134
3134
I used passwordless authentication, I think no need of providing password.
– Janith
Nov 15 at 5:35
When I using above command I am getting error.wget
is working butscp
is not working.
– Janith
Nov 15 at 5:42
Note that if the named file already exists, wget will download intofilename.1
,filename.2
, etc.
– Ulrich Schwarz
Nov 15 at 5:52
Yes can I write a scrip to download and copy to remote machine same time?
– Janith
Nov 15 at 6:00
add a comment |
I used passwordless authentication, I think no need of providing password.
– Janith
Nov 15 at 5:35
When I using above command I am getting error.wget
is working butscp
is not working.
– Janith
Nov 15 at 5:42
Note that if the named file already exists, wget will download intofilename.1
,filename.2
, etc.
– Ulrich Schwarz
Nov 15 at 5:52
Yes can I write a scrip to download and copy to remote machine same time?
– Janith
Nov 15 at 6:00
I used passwordless authentication, I think no need of providing password.
– Janith
Nov 15 at 5:35
I used passwordless authentication, I think no need of providing password.
– Janith
Nov 15 at 5:35
When I using above command I am getting error.
wget
is working but scp
is not working.– Janith
Nov 15 at 5:42
When I using above command I am getting error.
wget
is working but scp
is not working.– Janith
Nov 15 at 5:42
Note that if the named file already exists, wget will download into
filename.1
, filename.2
, etc.– Ulrich Schwarz
Nov 15 at 5:52
Note that if the named file already exists, wget will download into
filename.1
, filename.2
, etc.– Ulrich Schwarz
Nov 15 at 5:52
Yes can I write a scrip to download and copy to remote machine same time?
– Janith
Nov 15 at 6:00
Yes can I write a scrip to download and copy to remote machine same time?
– Janith
Nov 15 at 6:00
add a comment |
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%2f481849%2fwget-and-scp-as-a-pipeline%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