How to download a file in bash from a download PHP script?

07
2014-07
  • congliu

    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:

    http://www.vim.org/scripts/download_script.php?src_id=17123

  • Answers
  • BenjiWiebe
    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!)

  • stib
    curl -o output.zip http://www.vim.org/scripts/download_script.php?src_id=17123
    

    works for me.


  • Related Question

    Write a PID file manually from Bash script
  • DerMike


    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?


  • Related Answers
  • Jeremy Sturdivant

    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.

  • grawity
    #!/bin/bash
    echo $$ > fooapp.pid
    exec fooapp
    

    As mentioned earlier, exec replaces bash with the specified program, retaining the PID.