SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face shell script in php

    i have some problem to shell script using php...
    my script is file is a.sh:::

    #!/bin/sh

    echo "ATZ0" > /dev/ttyACM0
    echo "AT+CSCA?" > /dev/ttyACM0
    echo "AT+CMGF=1" > /dev/ttyACM0
    echo "AT+CNMI=2,1" > /dev/ttyACM0
    echo "AT+CMGS=\"09924927267\"" > /dev/ttyACM0
    echo "hello\32" > /dev/ttyACM0

    and my php file is index.php::

    <?php
    exec("./a.sh");

    ?>

    i cant run this script...pls help me with this

  2. #2
    John 8:24 JREAM's Avatar
    Join Date
    Sep 2007
    Location
    Florida
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    See if this does anything:

    PHP Code:
    $output shell_exec('./a.sh');
    echo 
    "<pre>$output</pre>"
    src: http://php.net/manual/en/function.shell-exec.php

  3. #3
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nothing is happening...

  4. #4
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,198
    Mentioned
    72 Post(s)
    Tagged
    3 Thread(s)
    Try using your full path from root e.g. /home/user/www/a.sh and CHMOD the shell script to 777.

    PHP Code:
    <?php
    exec
    (" /home/user/www/a.sh ");
    ?>
    Last edited by Rubble; Mar 13, 2010 at 08:33. Reason: Added the code

  5. #5
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    still its not working should i shift to another platform like jsp??

  6. #6
    SitePoint Zealot
    Join Date
    Jul 2007
    Location
    Macomb, MI USA
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It looks liek you are trying to access a modem or serial port? If so, this should help you:
    http://www.lspace.nildram.co.uk/freeware.html

    -Bing
    inClick Ad Server - Start Your Own Performance Based Ad Network
    Key Features | Download inClick Now | Free Ad Server Hosting Offer

  7. #7
    SitePoint Wizard
    Join Date
    Mar 2008
    Posts
    1,149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You might be able to write to /dev/ttyACM0 directly from PHP with proc_open().


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •