No se si te servira: Este codigo acepta parámetros del tipo ./programa.php -f 20040801 -p ME , lo bueno es que no tienes que pasar los parámetros en orden ni todos obligatoriamente.
#!/usr/bin/php -q <?php // Recibe Parametros array_shift($argv); while(count($argv) > 0){ $opcion = array_shift($argv); switch($opcion){ case "-p": $prod = array_shift($argv); break; case "-c": $cuerpos = array_shift($argv); break; case "-f": $fecha = array_shift($argv); break; case "-?": ayuda(); exit; break; default: ayuda(); exit; break; } } // Parametros por defecto if(!isset($fecha)){ $fecha = date("Ymd",mktime(0,0,0,date("m"),date("d")+1,date("Y"))); } if(!isset($prod)){ $prod = "ME"; } ?> Y este otro simplemente los saca por orden, osea ejecutando asi ./programa.php ME 20040801 #!/usr/bin/php -q <?php if($argc >= 3){ $fecha = $argv[2]; }else{ $fecha = date("Ymd"); } if($argc >= 2){ $prod = $argv[1]; }else{ $prod = "ME"; } ?> Saludos Jaime Lagos -----Mensaje original----- De: Edgard Pineda Leone. [mailto:[EMAIL PROTECTED] Enviado el: Lunes, 09 de Agosto de 2004 18:00 Para: Discusion de Linux en Castellano Asunto: Re: pasar parametros a ejecutables #! On Mon, 9 Aug 2004, Ricardo Mun~oz A. wrote: > El lun, 09-08-2004 a las 16:38, Edgard Pineda Leone. escribió: > > On Mon, 9 Aug 2004, Ricardo Mun~oz A. wrote: > > [...] > > ahora si, te capte... si haces un 'man bash' luego buscas /#! aparece lo > siguiente: > > "If the program is a file beginning with #!, the remainder of the first > line specifies an interpreter for the program. The shell executes the > specified interpreter on operating systems that do not handle this exe- > cutable format themselves. The arguments to the interpreter consist of > a single optional argument following the interpreter name on the first > line of the program, followed by the name of the program, followed by > the command arguments, if any." > > donde dice _single optional argument_ creo se refiere a tu problema... > por lo tanto el comentario de Alvaro de que "PHP es un lenguaje sin > esperanza" fue totalmente innecesario... Cierto... :( tendré que parsear la salida simplemente... es facil pero no es "limpio" como me hubiera gustado. Gracias!!! Edgard Pineda. ***************************************************** Su mensaje fue revisado por el antivirus corporativo *****************************************************