M
M
Madion2016-04-27 14:29:54
bash
Madion, 2016-04-27 14:29:54

How to run a bash script right after a file is downloaded via wget?

Hello.
Wget downloads the file:

wget -qcO '/var/www/admin/test.yml' http://site.ru/file.yml

The file may take more than 2 hours to download.
You need to run another bash command immediately after downloading the file. How to do it?
This does not work:
wget -qcO '/var/www/admin/test.yml' http://site.ru/file.yml && sh '/var/www/admin/command.sh'

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Selivanov, 2016-04-27
@selivanov_pavel

wget -qcO '/var/www/admin/test.yml' http://site.ru/file.yml ; sh '/var/www/admin/command.sh'

&&will only work if the exit code of the previous command is 0. ;- always
If this is a script, then it is enough to write the following command on a new line, this is the same as ;
Or you can escape the line break in the shell:
wget -qcO '/var/www/admin/test.yml' http://site.ru/file.yml \
sh '/var/www/admin/command.sh'

V
Vladimir Kuts, 2016-04-27
@fox_12

and so?
Naturally, the script must be with launch rights and a link to the shell in the first line

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question