Unable to attach to remote geth: dial unix ///home/ubuntu/.ethereum/testnet/geth.ipc: connect: permission denied

2017-12-11 12:24:18

I have created a shell script on a ubuntu server X with geth Node installed,to insert data in a smart contract in testnet blockchain. Further I am executing the shell script from a PHP file insertscript.php created on the same server X by using shell_exec command. When I call the PHP script from the command prompt , it gets successfully executed and data gets inserted in the blockchain . But when I call the php script from another server by using cURL or open it in the browser, I will see the error :

Fatal: Unable to attach to remote geth: dial unix ///home/ubuntu/.ethereum/testnet/geth.ipc: connect: permission denied

My shell script looks something like:-

#!/bin/sh

ATTACHPARAMETER="ipc:///home/ubuntu/.ethereum/testnet/geth.ipc"

INCIDENTUUID=${1:-"photo-55697b7f4a550511448499999999"}

USERUUID=${2:-"null"}

TIMESTAMP=$3

STATUS=$4

echo $INCIDENTUUID

echo $USERUUID

echo $TIMESTAMP

echo $STATUS

geth attach $ATTACHPARAMETER << EOF

var abi = [abi definition];

var address