1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Development Can I execute a bash script from php? (not sh)

Discussion in 'Software' started by OneSeventeen, 5 Nov 2010.

  1. OneSeventeen

    OneSeventeen Oooh Shiny!

    Joined:
    3 Apr 2002
    Posts:
    3,454
    Likes Received:
    2
    Every time I use any of PHP's built in exec() functions it launches sh, which on my Ubuntu server is symlinked to dash.

    I have added:
    Code:
    #!/bin/bash
    to the top of my .sh file, and even told PHP to exec("bash myScript.sh"); but still no dice.

    I'd love to just have all of my scripts execute using bash instead of sh.

    tips? advice?
     
  2. OneSeventeen

    OneSeventeen Oooh Shiny!

    Joined:
    3 Apr 2002
    Posts:
    3,454
    Likes Received:
    2
    Works beautifully:
    PHP:
    $arp exec("/usr/sbin/arp -a|sed 's/ /,/g'>arp.csv"$output$exit_code);
    Lesson:
    don't name your output files the same as the command you use to get them!
    :duh:
     

Share This Page