Executing from shell , not from php


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Executing from shell , not from php
# 1  
Old 07-22-2014
Executing from shell , not from php

Hi,

When I run command from php as www-data:
cordova platform add android
.. I get error without any solution in google.
But when I run it from shell (also as www-data) - it works!
So.. how to do to run this command from php but in shell (tty) not from php?

Regards!
# 2  
Old 07-22-2014
How are you running the command from php (post a code sample)? What error do you get?
# 3  
Old 07-22-2014
I run exactly:
$output = shell_exec("cordova platform add android");
but it should be run in folder project but not in Document Root huh - and therefore there is the problem I think (I answered for my question maybe). Unfortunatelly there isn't way to tell command cordova to it run in another directory then current "." , cd project ; cordova... doesn't work

So how to run "cordova platform add android" in different folder than "." ?
# 4  
Old 07-23-2014
If you've cd'd into project then '.' is 'project'.

Are you doing it in one shell_exec() call? i.e.
Code:
$output = shell_exec("cd project; cordova platform add android");

# 5  
Old 07-25-2014
Exactly, I'm doing this with command:
$output = shell_exec("cd project; cordova platform add android");and this isn't working.

But if I'm in shell and cd project and cordova... - everything works.
# 6  
Old 07-25-2014
What do you get from:
Code:
$output = shell_exec("cd project; pwd");

Also, check cordova in your interactive shell isn't aliased to something.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Executing Shell Script from PHP Webpage

Hello , I am trying to execute a small shell script from a PHP Webpage. Below is the shell script : 1.sh $ cat /home/oracle/rahul/1.sh #!/bin/ksh echo "`date` : Report generation in progress" > /home/oracle/rahul/report.txt echo "Run successfully script"; Below is the PHP... (1 Reply)
Discussion started by: rahul2662
1 Replies

2. Shell Programming and Scripting

Why we use -f while executing any shell script?

Hi All, I wanted to know why we use the '-f' option while executing script. in my case... abcd.sh -f any_evts 02 2014 abcd = Scriptname -f = dont know any_evts = Some file or string 02= month 2014 = year So in above pleas ehelp to understand here -f and other arguement like... (1 Reply)
Discussion started by: ajju
1 Replies

3. Shell Programming and Scripting

Executing a shell script using sh

Platform : Solaris 10, RHEL 5.4, OEL 6 I've noticed that some of my colleagues execute scripts by typing sh before the script name sh myscript.shI always execute a script by typing the script name and typing enter provided PATH variable has . (current directory) in it myscript.sh (and... (1 Reply)
Discussion started by: John K
1 Replies

4. Shell Programming and Scripting

Executing a shell script

LD_LIBRARY_PATH=~/tme-0.8/bus/multibus:~/tme-0.8/bus/sbus:~/tme-0.8/dist/softfloat/softfloat/bits32:~/tme-0.8/dist/softfloat/softfloat/bits64:~/tme-0.8/generic:~/tme-0.8/host/bsd:~/tme-0.8/host/gtk:~/tme-0.8/host/posix:~/tme-0.8/ic:~/tme-0.8/ic/ieee754:~/tme-0.8/ic/m68k:~/tme-0.8/ic/sparc:~/tme-0.8/... (1 Reply)
Discussion started by: lucky7456969
1 Replies

5. UNIX for Dummies Questions & Answers

Why is this shell not executing?

%touch nu %cat nu who | wc -l %chmod +x nu %nu nu: Command not found (5 Replies)
Discussion started by: Shaun74
5 Replies

6. Shell Programming and Scripting

Executing Scripts from PHP Web Interface

Later Edit: So far the problem is solved, i've loaded the .profile into the bash script, and now it's working great But I might have some future questions, so please don't close the thread. Thanks Hello everyone, I am trying to develop an web interface, which is able to execute pre-defined... (0 Replies)
Discussion started by: SuperDuck
0 Replies

7. Programming

c executing shell problem

Hello im geting error here: #include <stdlib.h> #include <stdio.h> using namespace std; int main (int argc, char *argv) { char user; string command; cin << user; command = printf ("grep '%s' /etc/shadow", user); system (command.c_str()); } return 0; } it should search shadow... (6 Replies)
Discussion started by: velniaszs
6 Replies

8. UNIX for Dummies Questions & Answers

Difference between executing a shell using sh and .

Is there any difference in executing the shell using sh and . and ./. I had a shell script and i observed that anyone is ale to execute the script eith sh even without having the execute permission.how is so? (2 Replies)
Discussion started by: soumyo_das
2 Replies

9. UNIX for Dummies Questions & Answers

Executing a Shell Script

I am trying to run a shell script using the ./<ScriptName> command, but the server returns an error bash: ./Script1.sh: Permission denied What variable do I need to set to avoid this? (4 Replies)
Discussion started by: igandu
4 Replies

10. UNIX for Dummies Questions & Answers

Executing Shell Scripts

Hi, I'm pretty new to Unix and I just have a question concerning making a script executable without putting the "sh" command before it. In case it makes the difference I am on an Apple computer using the Terminal. Anyway here is the little test code I wrote followed by the commands I took to try... (1 Reply)
Discussion started by: BuyoCat
1 Replies
Login or Register to Ask a Question