greetings,
pretty new to php and i think i might be missing some fundamental limitation of isset. i have two php scripts below that are executed by crond, one using --host X and one that does not. and below that are three different attempts at generating a command line that will be executed. the first example using strlen works as expected. please see bottom of thread for the command line that is generated for each php script respectively. when i came across isset it seemed to make more sense to use that instead, especially the third example. HOWEVER, both isset examples fail when $server is the value for -host. as you might guess -host is $host, --server is $server and --path is $path. is this an issue of having $server twice on the same line when using isset? i've been tinkering with this off and on for a few days and i'm stumped. i need not be spoon fed but some plain speak on what i might be misunderstanding would be great, thanks.
grid_lmx_capture_test.php --server=t70aic100 --host=denasv004 --path=/opt/IBM/lmx/bin --port=6200
grid_lmx_capture_test.php --server=t70aic100 --path=/opt/IBM/lmx/bin --port=6200
if (strlen($host)) {
$command2 = "ssh -o ConnectTimeout=60 $server \"cd $path ; " . (strlen($path) ? $path . "/": "") . "lmxendutil -licstat -port $port -host $host 2> /dev/null\"";
}elseif (!strlen($host)) {
$command2 = "ssh -o ConnectTimeout=60 $server \"cd $path ; " . (strlen($path) ? $path . "/": "") . "lmxendutil -licstat -port $port -host $server 2> /dev/null\"";
}
if (isset($host)) {
$command2 = "ssh -o ConnectTimeout=60 $server \"cd $path ; " . (strlen($path) ? $path . "/": "") . "lmxendutil -licstat -port $port -host $host 2> /dev/null\"";
}elseif (!isset($host)) {
$command2 = "ssh -o ConnectTimeout=60 $server \"cd $path ; " . (strlen($path) ? $path . "/": "") . "lmxendutil -licstat -port $port -host $server 2> /dev/null\"";
}
if (isset($host)) {
$command2 = "ssh -o ConnectTimeout=60 $server \"cd $path ; " . (strlen($path) ? $path . "/": "") . "lmxendutil -licstat -port $port -host $host 2> /dev/null\"";
}else{
$command2 = "ssh -o ConnectTimeout=60 $server \"cd $path ; " . (strlen($path) ? $path . "/": "") . "lmxendutil -licstat -port $port -host $server 2> /dev/null\"";
}
when using strlen example:
ssh -o ConnectTimeout=20 t70aic100 "cd /opt/IBM/lmx/bin ; /opt/IBM/lmx/bin/lmxendutil -licstat -port 6200 -host denasv004 2> /dev/null"
ssh -o ConnectTimeout=20 t70aic100 "cd /opt/IBM/lmx/bin ; /opt/IBM/lmx/bin/lmxendutil -licstat -port 6200 -host t70aic100 2> /dev/null"
when using either isset example:
ssh -o ConnectTimeout=20 t70aic100 "cd /opt/IBM/lmx/bin ; /opt/IBM/lmx/bin/lmxendutil -licstat -port 6200 -host denasv004 2> /dev/null"
ssh -o ConnectTimeout=20 t70aic100 "cd /opt/IBM/lmx/bin ; /opt/IBM/lmx/bin/lmxendutil -licstat -port 6200 -host 2> /dev/null"