Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8975313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:50:48+00:00 2026-06-15T18:50:48+00:00

I have a php file which needs to be executed in CLI from my

  • 0

I have a php file which needs to be executed in CLI from my Php application which runs on CodeIgniter framework. I tried the exec and shell_exec command and it seems to not start the process. Please find the code below which I try to execute.

$phpPath = exec('which php');
$cmd = $phpPath.' '.dirname(__DIR__).'/API/notification/NotificationServer.php';
echo "<pre>".shell_exec($cmd)."</pre>";

When I try running the above in Terminal it executes fine. I need to automatically trigger this once the user has a session set.

The path/$cmd variable prints

when I print the variable $cmd i get the below output, and the below when given in terminal works fine.

/usr/bin/php /Users/lalithb/Desktop/Android/AndroidWS/API/notification/NotificationServer.php

the above command works fine in the Terminal. When i try to exec/shell_exec it, it is not working.

APACHE_ERROR LOGS ARE :

sh: line 1:  2437 Trace/BPT trap: 5       /usr/bin/php
sh: line 1: /Users/lalithb/Desktop/Android/AndroidWS/API/notification/NotificationServer.php: Permission denied

Can someone help me out in running this above code in CLI ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T18:50:50+00:00Added an answer on June 15, 2026 at 6:50 pm

    I solved the problem, Guess there would be someone else like me trying to access the restricted folders. I found the solution here

    http://ubuntuforums.org/showthread.php?t=1302259

    exec('chmod +x'.dirname(__DIR__).'/API/notification/NotificationServer.php);
    

    The above worked the magic.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php file which checks for login and password from users database,
i have a php file from which i need to call a shell script
i have a php file which stores a variable, and i need to create
I have an XML file which I need to parse using PHP and send
I have a php file which has some variables like $name1, $name2... How can
I have a PHP file which my clients will execute on their server. It
I have a PHP file which will return something like <div id=title>Add Us On
i have one php file which process adding of record in Database fro array.
I have a php file which has a require_once Statement (?) this file is
I have a small php file which just creates the tables in a database.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.