je dois appeler un script PHP qui prend des arguments ..script PHP avec des arguments Écrasé par session SSH non interactif ne fonctionne pas
php /home/flintarm/www/store/magmi-importer/cli/magmi.cli.php -profile=Category -mode=create -logger=CLILogger
Cela fonctionne parfaitement bien si je me connecter avec PuTTY et ont une connexion interactive.
J'essaie d'appeler cette ligne de commande à partir d'une tâche complémentaire SSIS. (COSY Exécuter SSH tâche, n'a pas vraiment d'importance) qui semble fonctionner de manière non interactive.
Quand il exécute le coup d'envoi, mais ne tient pas compte php
bien les arguments (il est donc pas bien)
est inférieure à la source PHP ..
<?php
/**
* MAGENTO MASS IMPORTER CLI SCRIPT
*
* version : 0.1
* author : S.BRACQUEMONT aka dweeves
* updated : 2010-08-02
*
*/
require_once(dirname(dirname(__FILE__))."/inc/magmi_defs.php");
require_once('magmi_loggers.php');
$script=array_shift($argv);
function buildOptions($argv)
{
$options=array();
foreach($argv as $option)
{
$isopt=$option[0]=="-";
if($isopt)
{
$optarr=explode("=",substr($option,1),2);
$optname=$optarr[0];
if(count($optarr)>1)
{
$optval=$optarr[1];
}
else
{
$optval=1;
}
$options[$optname]=$optval;
}
}
return $options;
}
function getClassInstance($cval,$cdir=".")
{
$cdef=explode(":",$cval);
$cname=$cdef[0];
$cclass=$cdef[1];
$cinst=null;
$cfile="$cdir/$cname.php";
if(file_exists($cfile))
{
require_once($cfile);
if(class_exists($cclass))
{
$cinst=new $cclass();
}
}
if($cinst==null)
{
die("Invalid class definition : ".$cval);
}
return $cinst;
}
function getEngineInstance($options)
{
if(!isset($options["engine"]))
{
$options["engine"]="magmi_productimportengine:Magmi_ProductImportEngine";
}
$enginst=getClassInstance($options["engine"],dirname(dirname(__FILE__))."/engines");
return $enginst;
}
$options=buildOptions($argv);
$importer=getEngineInstance($options);
if(isset($importer))
{
$loggerclass=isset($options['logger'])?$options['logger']:"FileLogger";
$importer->setLogger(new $loggerclass());
if(!isset($options["chain"]))
{
$options["chain"]=isset($options["profile"])?$options["profile"]:"";
$options["chain"].=isset($options["mode"])?":".$options["mode"]:"";
}
$pdefs=explode(",",$options["chain"]);
foreach($pdefs as $pdef)
{
$pm=explode(":",$pdef);
$eargv=array();
if(!empty($pm[0]))
{
$eargv[]="-profile=".$pm[0];
}
if(isset($pm[1]))
{
$eargv[]="-mode=".$pm[1];
}
$eoptions=buildOptions($eargv);
$importer->run(array_merge($eoptions,$options));
}
}
?>
Je n'ai pas le SSH exacte commande car elle se trouve dans le code du composant SSIS. Le « bavard » LOGGUE produit montre ceci:
2015-09-18 16:36:13.459 VERBOSE SshSession(1)[6] SSH: Received packet SSH_MSG_USERAUTH_SUCCESS (1 bytes).
0000 |34 | 4
2015-09-18 16:36:13.459 DEBUG SshSession(1)[6] SSH: Authentication successful.
2015-09-18 16:36:13.459 VERBOSE SshSession(1)[6] SSH: Sending packet SSH_MSG_CHANNEL_OPEN (24 bytes).
0000 |5A-00-00-00-07-73-65-73 73-69-6F-6E-00-00-00-00| Z....session....
0010 |00-02-00-00-00-00-40-00 | [email protected]
2015-09-18 16:36:13.490 VERBOSE SshSession(1)[6] SSH: Received packet SSH_MSG_CHANNEL_OPEN_CONFIRMATION (17 bytes).
0000 |5B-00-00-00-00-00-00-00 00-00-00-00-00-00-00-80| [...............
0010 |00 | .
2015-09-18 16:36:13.490 DEBUG SshSession(1)[6] SSH: Executing command 'php /home/flintarm/www/store/magmi-importer/cli/magmi.cli.php -profile=Category -mode=create -logger=CLILogger'.
2015-09-18 16:36:13.490 VERBOSE SshSession(1)[6] SSH: Sending packet SSH_MSG_CHANNEL_REQUEST (128 bytes).
0000 |62-00-00-00-00-00-00-00 04-65-78-65-63-01-00-00| b........exec...
0010 |00-6E-70-68-70-20-2F-68 6F-6D-65-2F-66-6C-69-6E| .nphp /home/flin
0020 |74-61-72-6D-2F-77-77-77 2F-73-74-6F-72-65-2F-6D| tarm/www/store/m
0030 |61-67-6D-69-2D-69-6D-70 6F-72-74-65-72-2F-63-6C| agmi-importer/cl
0040 |69-2F-6D-61-67-6D-69-2E 63-6C-69-2E-70-68-70-20| i/magmi.cli.php
0050 |2D-70-72-6F-66-69-6C-65 3D-43-61-74-65-67-6F-72| -profile=Categor
0060 |79-20-2D-6D-6F-64-65-3D 63-72-65-61-74-65-20-2D| y -mode=create -
0070 |6C-6F-67-67-65-72-3D-43 4C-49-4C-6F-67-67-65-72| logger=CLILogger
2015-09-18 16:36:13.537 VERBOSE SshSession(1)[6] SSH: Received packet SSH_MSG_CHANNEL_WINDOW_ADJUST (9 bytes).
0000 |5D-00-00-00-00-00-20-00 00 | ]..... ..
2015-09-18 16:36:13.537 VERBOSE SshSession(1)[6] SSH: Received packet SSH_MSG_CHANNEL_SUCCESS (5 bytes).
0000 |63-00-00-00-00 | c....
Afficher la commande SSH que vous exécuter. – Barmar
Quelques éléments à modifier dans votre question: Quelle est la commande envoyée via SSH? Par "coups d'envoi du php" voulez-vous dire qu'il fonctionne le script? Ou juste PHP en général? Si le script lui-même est en cours d'exécution, essayez un 'print_r ($ argv)' afin que vous puissiez voir comment PHP voit les arguments transmis. Il se peut qu'ils soient tous regroupés dans le premier argument, ou manquant entièrement, selon la commande qui est envoyée via SSH. –
J'ai mis à jour le message pour afficher le journal de SSIS SSH addon – user1005246