php-cli command is not found

General discussion on Zend Server for IBM System i
Post Reply
dan8246
Posts: 40
Joined: Fri Jan 23, 2015 5:53 pm

php-cli command is not found

Post by dan8246 » Tue Sep 01, 2015 1:57 pm

Overall I'm trying to use composer, but the problem I'm having is php-cli is not in the environment path. I now know I can create a file ".profile" in my home directory in order to add it to my path but a previous solution attempt is causing other issues.

If I used the absolute path "/usr/local/zendsvr6/bin/php-cli" the system was able to find it, but the output would appear to be garbage when running this command:

Code: Select all

/usr/local/zendsvr6/bin/php composer.phar install


I came across this article https://support.zend+.+com/hc/en-us/articles/206212087-Set-IBM-i-PASE-environment-variables-for-php-cli- and followed the instructions using my fcgi env variables but had no luck, so I reverted. By reverted I mean I made a duplicate of the original before any changes and then renamed it back without ever editing the duplicate. Now when I use the absolute path I used before, the command is no longer found but it clearly exist at that location and the permissions are exactly the same as the other files in the directory.

This is whats displayed:

Code: Select all

$
/usr/local/zendsvr6/bin/php-cli -v
/QOpenSys/usr/bin/-sh: /usr/local/zendsvr6/bin/php-cli: not found
$
Does anyone know what is going on here? And thoughts on how to correct it?

Note*: I can't post URL links so I just added "+" to any links.

scottgcampbell
Posts: 187
Joined: Wed Apr 22, 2009 2:29 pm
Location: Edmonton, AB, Canada

Re: php-cli command is not found

Post by scottgcampbell » Tue Sep 01, 2015 2:26 pm

what do you get when you are in QP2TERM and do:

Code: Select all

ls -l /usr/local/zendsvr6/bin/php-cli  
and

Code: Select all

cat /usr/local/zendsvr6/bin/php-cli  
Scott

dan8246
Posts: 40
Joined: Fri Jan 23, 2015 5:53 pm

Re: php-cli command is not found

Post by dan8246 » Tue Sep 01, 2015 3:09 pm

For the first:

Code: Select all

----r-xr-x    1 137      0               232 Aug 31 16:17 /usr/local/zendsvr6/bin/php-cli
For the second:

Code: Select all

#!/bin/sh                                               
if [ -f /usr/local/zendsvr6/etc/zce.rc ];then           
    . /usr/local/zendsvr6/etc/zce.rc                    
else                                                    
    echo "/usr/local/zendsvr6/etc/zce.rc doesn't exist!"
    exit 1;                                             
fi                                                      
LIBPATH=$ZCE_PREFIX/lib                                 
$ZCE_PREFIX/bin/php.bin "$@"                            

scottgcampbell
Posts: 187
Joined: Wed Apr 22, 2009 2:29 pm
Location: Edmonton, AB, Canada

Re: php-cli command is not found

Post by scottgcampbell » Tue Sep 01, 2015 3:41 pm

Here is what I have for the ls, your permissions don't look quite right to me....

Code: Select all

$                                                                            
ls -l /usr/local/zendsvr6/bin/php-cli                                        
-rwxr-xr-x  1 QSECOFR  0                   223 Feb  4  2015 /usr/local/zendsvr6/bin/php-cli   
so depending on who 137 is and who is running script the problem may be that they don't have permission to even see php-cli.

Scott

dan8246
Posts: 40
Joined: Fri Jan 23, 2015 5:53 pm

Re: php-cli command is not found

Post by dan8246 » Tue Sep 01, 2015 3:55 pm

137 is a group which I am apart of. I am running this in a 5250 terminal under my login.

I just gave the file the same exact permissions as yours plus more and it still can't find it.

Code: Select all

-rwxr-xrwx    1 qsecofr  0               232 Aug 31 16:17 /usr/local/zendsvr6/bin/php-cli

scottgcampbell
Posts: 187
Joined: Wed Apr 22, 2009 2:29 pm
Location: Edmonton, AB, Canada

Re: php-cli command is not found

Post by scottgcampbell » Tue Sep 01, 2015 4:28 pm

Does it work if you add it to your path manually then call php-cli -v

Code: Select all

export PATH=$PATH:/usr/local/zendsvr6/bin
export
php-cli -v

dan8246
Posts: 40
Joined: Fri Jan 23, 2015 5:53 pm

Re: php-cli command is not found

Post by dan8246 » Tue Sep 01, 2015 4:47 pm

I added the location to my path manually and then echoed my $PATH variable and tried php-cli. No luck.
I used the second export as well and that confirmed what the echo displayed, it was in my path variable.

Code: Select all

export PATH=$PATH:/usr/local/zendsvr6/bin
echo $PATH
/QOpenSys/usr/bin:/usr/ccs/bin:/QOpenSys/usr/bin/X11:/usr/sbin:.:/usr/bin:/usr/local/zendsvr6/bin
php-cli -v
/QOpenSys/usr/bin/-sh: php-cli:  not found.

scottgcampbell
Posts: 187
Joined: Wed Apr 22, 2009 2:29 pm
Location: Edmonton, AB, Canada

Re: php-cli command is not found

Post by scottgcampbell » Tue Sep 01, 2015 4:55 pm

After you do the export does a which know where it is?
Just wondering if it looks like a path or permissions issue (very strange either way)

Code: Select all

$                                                                           
which php-cli                                                               
no php-cli in /QOpenSys/usr/bin /usr/ccs/bin /QOpenSys/usr/bin/X11 /usr/sbin
. /usr/bin                                                                  
$                                                                           
export PATH=$PATH:/usr/local/zendsvr6/bin                                   
$                                                                           
which php-cli                                                               
/usr/local/zendsvr6/bin/php-cli                                             

dan8246
Posts: 40
Joined: Fri Jan 23, 2015 5:53 pm

Re: php-cli command is not found

Post by dan8246 » Tue Sep 01, 2015 4:58 pm

A which knows where it is:

Code: Select all

which php-cli
/usr/local/zendsvr6/bin/php-cli

dan8246
Posts: 40
Joined: Fri Jan 23, 2015 5:53 pm

Re: php-cli command is not found

Post by dan8246 » Thu Sep 03, 2015 1:33 pm

I ended up opening a ticket with Zend.

It turns out the issue was due to the end of line characters on my file. The built in text editor with iNavigator is not UNIX safe so when I saved a backup of the original file it saved it with CRLF as the line endings. All I had to do was changed those eol characters to just CR.

I used Zend Studio to confirm the issue by going to 'Window -> Preferences -> General -> Editors -> Text Editors -> and check 'Show whitespace characters'.
I then changed those eol characters by going to 'File -> Convert Line Delimiters To' and selected Unix.

Post Reply