I am trying to call a php script through a shell script.The script is to be called as the run on receive directive of gammu-smsd.My php script executes as expected when I call it using

/opt/lampp/bin/php myvarsreader.php

.However on trying to run my script(From terminal):

#!/bin/sh
PROGRAM=/opt/lampp/bin/php myvarsreader.php
    eval "$PROGRAM \"\${SMS_${i}_NUMBER}\" \"\${SMS_${i}_TEXT}\""
    echo $? 
    echo "$PROGRAM \"\${SMS_${i}_NUMBER}\" \"\${SMS_${i}_TEXT}\"" >> ran1date

I get the following error message

./first.sh: 17: myvarsreader.php: not found
eval: 1: : Permission denied
127

myvarsreader.php permissions are:-rwxrwxrwx,so I don't understand the permission denied part.
I am running ubuntu 10

I am trying to call a php script through a shell script.The script is to be called as the run on receive directive of gammu-smsd.My php script executes as expected when I call it using

/opt/lampp/bin/php myvarsreader.php

.However on trying to run my script(From terminal):

#!/bin/sh
PROGRAM=/opt/lampp/bin/php myvarsreader.php
    eval "$PROGRAM \"\${SMS_${i}_NUMBER}\" \"\${SMS_${i}_TEXT}\""
    echo $? 
    echo "$PROGRAM \"\${SMS_${i}_NUMBER}\" \"\${SMS_${i}_TEXT}\"" >> ran1date

I get the following error message

./first.sh: 17: myvarsreader.php: not found
eval: 1: : Permission denied
127

myvarsreader.php permissions are:-rwxrwxrwx,so I don't understand the permission denied part.
I am running ubuntu 10

Quote the command in assignment, i.e.

PROGRAM="/opt/lampp/bin/php myvarsreader.php"

Thanks ckoy,the php script is now called without any errors But no gammu-smsd environment variables are passed as arguments!?? Any suggestions?

If you want env vars to be accessible in a script, you must export them.
Another option is to pass them as arguments to the script but that requires some shell scripting knowledge.

OK so would you be kind enough to give a few ideas on how to go about exporting.By the way the .sh script is called by gammu-smsd does this change anything??

This article has been dead for over six months. Start a new discussion instead.