wget and scp as a pipeline
Clash Royale CLAN TAG#URR8PPP
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 yesterday
Jeff Schaller
35.9k952119
35.9k952119
asked yesterday
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
yesterday
When I using above command I am getting error.wget
is working butscp
is not working.
– Janith
yesterday
Note that if the named file already exists, wget will download intofilename.1
,filename.2
, etc.
– Ulrich Schwarz
yesterday
Yes can I write a scrip to download and copy to remote machine same time?
– Janith
yesterday
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 yesterday
dirkt
16k21234
16k21234
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
yesterday
When I using above command I am getting error.wget
is working butscp
is not working.
– Janith
yesterday
Note that if the named file already exists, wget will download intofilename.1
,filename.2
, etc.
– Ulrich Schwarz
yesterday
Yes can I write a scrip to download and copy to remote machine same time?
– Janith
yesterday
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
yesterday
When I using above command I am getting error.wget
is working butscp
is not working.
– Janith
yesterday
Note that if the named file already exists, wget will download intofilename.1
,filename.2
, etc.
– Ulrich Schwarz
yesterday
Yes can I write a scrip to download and copy to remote machine same time?
– Janith
yesterday
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 yesterday
sla3k
3134
3134
I used passwordless authentication, I think no need of providing password.
– Janith
yesterday
When I using above command I am getting error.wget
is working butscp
is not working.
– Janith
yesterday
Note that if the named file already exists, wget will download intofilename.1
,filename.2
, etc.
– Ulrich Schwarz
yesterday
Yes can I write a scrip to download and copy to remote machine same time?
– Janith
yesterday
add a comment |
I used passwordless authentication, I think no need of providing password.
– Janith
yesterday
When I using above command I am getting error.wget
is working butscp
is not working.
– Janith
yesterday
Note that if the named file already exists, wget will download intofilename.1
,filename.2
, etc.
– Ulrich Schwarz
yesterday
Yes can I write a scrip to download and copy to remote machine same time?
– Janith
yesterday
I used passwordless authentication, I think no need of providing password.
– Janith
yesterday
I used passwordless authentication, I think no need of providing password.
– Janith
yesterday
When I using above command I am getting error.
wget
is working but scp
is not working.– Janith
yesterday
When I using above command I am getting error.
wget
is working but scp
is not working.– Janith
yesterday
Note that if the named file already exists, wget will download into
filename.1
, filename.2
, etc.– Ulrich Schwarz
yesterday
Note that if the named file already exists, wget will download into
filename.1
, filename.2
, etc.– Ulrich Schwarz
yesterday
Yes can I write a scrip to download and copy to remote machine same time?
– Janith
yesterday
Yes can I write a scrip to download and copy to remote machine same time?
– Janith
yesterday
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