# Problem executing command as root.



## arie01 (Dec 6, 2012)

Hello, 

I logged in to my system as a regular user than I su'ed to root and then I tried to run a command and I got Permission denied. The root user is already a member of the wheel group. Why do I keet getting this error?

Thank you,


----------



## fonz (Dec 6, 2012)

arie01 said:
			
		

> I logged in to my system as a regular user than[sic] I su'ed to root and then I tried to run a command and I got Permission denied. The root user is already a member of the wheel group. Why do I keet[sic] getting this error?


What were the exact command and error message?

Fonz


----------



## chatwizrd (Dec 6, 2012)

More than likely you did not chmod() the file executable.


----------



## arie01 (Dec 6, 2012)

Hello Fonz, 

The exact command is 

`# /usr/local/www/lilac/export.php id=1`

It may be wrong, I am not sure how else to execute it.


----------



## fonz (Dec 6, 2012)

PHP scripts usually cannot be executed standalone, they need to be run by an interpreter. For example, something like `# [b]/usr/local/bin/php[/b] /usr/local/www/lilac/export.php id=1`

Fonz

P.S. Although in this case I can to some extent understand that you posted your question in this thread, you should in most cases start a new thread for your question instead of "hijacking" an existing one.


----------



## chatwizrd (Dec 6, 2012)

fonz said:
			
		

> PHP scripts usually cannot be executed standalone, they need to be run by an interpreter. For example, something like `# [b]/usr/local/bin/php[/b] /usr/local/www/lilac/export.php id=1`
> 
> Fonz



It is possible, but not recommended.


----------



## fonz (Dec 6, 2012)

chatwizrd said:
			
		

> *It* is possible, but not recommended.


What is "it", standalone execution or interpreter usage?

Fonz


----------



## arie01 (Dec 6, 2012)

Oh, sorry. Unfortunately, I know very little about the os and it's commands and also about using this forum. I searched on Google and this post came up. I read through it and saw that it may be the right post for my issue too, so I guess I highjacked it. 

IN any case, I run the command again as it appears in your reply and it looks like it might have run successfully. I have to check into it to make sure.

I'll check and post back tomorrow so whoever is facing the same issue like mine, will know what to do.

Thank you and sorry if I was a rude.


----------



## fonz (Dec 6, 2012)

arie01 said:
			
		

> Oh, sorry.
> [snip]
> I read through it and saw that it may be the right post for my issue too, so I guess I highjacked it.
> [snip]
> Thank you and sorry if I was a rude.


No, you weren't rude. And I didn't intend to appear angry either, it was just a gentle little hint :beer

Fonz


----------



## SirDice (Dec 7, 2012)

fonz said:
			
		

> P.S. Although in this case I can to some extent understand that you posted your question in this thread, you should in most cases start a new thread for your question instead of "hijacking" an existing one.


Agreed, posts split off into it's own thread.


----------



## chatwizrd (Dec 7, 2012)

fonz said:
			
		

> What is "it", standalone execution or interpreter usage?
> 
> Fonz



You just chmod() the php file executable and you can add a shebang to the top like the following to execute it.


```
#!/usr/local/bin/php

<?php
```


----------

