How to download a file in bash from a download PHP script?
2014-07
How to download a file in bash from a download PHP script?
For example, a file named nerdtree.zip that can be download by running this link in browser:
wget -O nerdtree.zip http://www.vim.org/scripts/download_script.php?src_id=17123
works for me. (I just couldn't leave this question be without a wget
answer!)
curl -o output.zip http://www.vim.org/scripts/download_script.php?src_id=17123
works for me.
How could I write a Bash-script that runs a long running program and stores the programs process id in a separate file?
I want something like
#!/bin/bash
exec long_running_tool
echo `ps af |grep "long_running_tool" |awk '$5 == "long_running_tool" {print $1}'` > pid_file
However doing exactly this would execute the ps
after tool has finished.
Is there a way to get the process id of the process created?
You can easily run the process in the background with "&", then get the PID of the background process using "$!"
#!/bin/bash
long_running_tool &
echo $! > pid_file
Then, optionally, wait $! if you want the shell to block until the process completes execution.
#!/bin/bash
echo $$ > fooapp.pid
exec fooapp
As mentioned earlier, exec
replaces bash
with the specified program, retaining the PID.