Global's work in http but not in ssh....
Moderator: General Moderators
Global's work in http but not in ssh....
hi guys, mabye someone here can explain this to me...
my script works fine when I call it from http but when i call the script using /usr/bin/php /path/to/script.php and it doesn't work....
I did some debugging and found out that $SCRIPT_NAME and $SCRIPT_FILENAME are not working when I call the script via ssh, but when i call via http it works just fine.... $_SERVER["SCRIPT_FILENAME"] / $_SERVER["SCRIPT_NAME"] worked in http but not ssh also....
anyone can help because this is REALLY anonying.... lol
my script works fine when I call it from http but when i call the script using /usr/bin/php /path/to/script.php and it doesn't work....
I did some debugging and found out that $SCRIPT_NAME and $SCRIPT_FILENAME are not working when I call the script via ssh, but when i call via http it works just fine.... $_SERVER["SCRIPT_FILENAME"] / $_SERVER["SCRIPT_NAME"] worked in http but not ssh also....
anyone can help because this is REALLY anonying.... lol
I have no idea what your saying.... are you saying that ssh uses a different php and that php.ini might have register globals off?Grim... wrote:The Apache server tells PHP to compile, and you don't use the Apache server when you SSH.
I'm not so hot at this stuff so I might be very wrong...
Let me chek.
maybe i am confusing you guys when I call $SCRIPT_NAME, $SCRIPT_FILENAME, PHP_SELF global var(s) what are they properly called? SERVER vars?agtlewis wrote:Well I'm really not sure how your posting data or populating $_GET $_SESSION or $_COOKIE globals via ssh. Globals don't cross scripts either unless it's an inlcude.
Then that's what I'm having a problem with....
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
I mean via SSH 100%, how can i get the script NAME of the .php from SHELL ? anyone know?arborint wrote:Do you mean SSH or HTTPS? If you are talking about SSH then PHP would not "work" because there is no webserver serving up SSH sessions. If you are saying that something works in HTTP but not in HTTPS then you should check you webserver configuration.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
What does that mean "how can i get the script NAME of the .php from SHELL"? If you are in the shell you would need to know the name of the script to execute it. If the script is running then $_SERVER['SCRIPT_NAME'] will give the script name. If you write a test script that calls phpinfo() it will dump all the globals that are available. That's ususally the first thing PHP programmers do on a system.
(#10850)
yea, see i did that phpinfo already in ssh.... and i didn't see the SCRIPT_NAME var, i see it in http but not in ssh...... that is the whole weird thing about this, why doesn't $_SERVER[''SCRIPT_NAME] show up?arborint wrote:What does that mean "how can i get the script NAME of the .php from SHELL"? If you are in the shell you would need to know the name of the script to execute it. If the script is running then $_SERVER['SCRIPT_NAME'] will give the script name. If you write a test script that calls phpinfo() it will dump all the globals that are available. That's ususally the first thing PHP programmers do on a system.
and the REASON I want the FILENAME and FILE PATH, is I automate the crud outta things, I like to rename my scripts say script_1.php or script_2.php and then my script will AUTOMATICALLY grab the number after _ in the script name? got it? good
anyways, since I can't figure this out , i am just using
script.php 'run=whatever&file_num=1'
script.php 'run=whatever&file_num=2'
that wasn't what i wanted, but i guess it might work out better.
What does this show?
Code: Select all
print_r($_SERVER['argv']);Code: Select all
#!/usr/bin/php
<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors', TRUE);
print_r($_SERVER);
echo "\n\n";
print_r($_ENV);
?>
timvw@madoka:~$ php test.php
Array
(
[TERM] => xterm
[SHELL] => /bin/bash
[HISTSIZE] => 300
[SSH_CLIENT] => ::ffff:62.235.234.49 32957 22
[CVSROOT] => /home/users/timvw/services/cvs
[SSH_TTY] => /dev/pts/29
[USER] => timvw
[LS_COLORS] => no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:
[TMOUT] => 259200
[MAIL] => /home/users/timvw/Maildir
[PATH] => /home/users/timvw/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/usr/lib/j2sdk1.5-sun/bin
[PWD] => /home/users/timvw
[PS1] => \\u@\\h:\\w\\$
[SHLVL] => 1
[HOME] => /home/users/timvw
[LOGNAME] => timvw
[CLASSPATH] =>
[SSH_CONNECTION] => ::ffff:62.235.234.49 32957 ::ffff:193.190.138.70 22
[_] => /usr/bin/php
[PHP_SELF] => test.php
[SCRIPT_NAME] => test.php
[SCRIPT_FILENAME] => test.php
[PATH_TRANSLATED] => test.php
[DOCUMENT_ROOT] =>
[argv] => Array
(
[0] => test.php
)
[argc] => 1
)
Array
(
[TERM] => xterm
[SHELL] => /bin/bash
[HISTSIZE] => 300
[SSH_CLIENT] => ::ffff:62.235.234.49 32957 22
[CVSROOT] => /home/users/timvw/services/cvs
[SSH_TTY] => /dev/pts/29
[USER] => timvw
[LS_COLORS] => no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:
[TMOUT] => 259200
[MAIL] => /home/users/timvw/Maildir
[PATH] => /home/users/timvw/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/usr/lib/j2sdk1.5-sun/bin
[PWD] => /home/users/timvw
[PS1] => \\u@\\h:\\w\\$
[SHLVL] => 1
[HOME] => /home/users/timvw
[LOGNAME] => timvw
[CLASSPATH] =>
[SSH_CONNECTION] => ::ffff:62.235.234.49 32957 ::ffff:193.190.138.70 22
[_] => /usr/bin/php
)