• Publicidad

system() no me imprime en PHP

¿Apenas comienzas con Perl? En este foro podrás encontrar y hacer preguntas básicas de Perl con respuestas aptas a tu nivel.

system() no me imprime en PHP

Notapor gorkalinux » 2009-10-21 06:59 @333

Tengo este código en PHP:

Sintáxis: [ Descargar ] [ Ocultar ]
Using php Syntax Highlighting
  1. echo '<pre>';
  2. $last_line = system('ls', $retval);
  3. echo '
  4. </pre>
  5. <hr />Last line of the output: ' . $last_line . '
  6. <hr />Return value: ' . $retval;
  7. echo '<pre>';
  8. $last_line = system('prueba.pl', $retval);
  9. echo '
  10. </pre>
  11. <hr />Last line of the output: ' . $last_line . '
  12. <hr />Return value: ' . $retval;
Coloreado en 0.020 segundos, usando GeSHi 1.0.8.4


Y me devuelve esto:

Sintáxis: [ Descargar ] [ Ocultar ]
Using text Syntax Highlighting
prueba.pl
prueba.pl~
 
--------------------------------------------------------------------------------
Last line of the output: prueba.pl~
--------------------------------------------------------------------------------
Return value: 0

--------------------------------------------------------------------------------
Last line of the output:
--------------------------------------------------------------------------------
Return value: 127
 
Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4


El primer resultado, el del 'ls', sale bien. ¿Por qué no salen los print() de mi programa 'prueba.pl'?

El fichero prueba.pl contiene:

Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. #!/usr/bin/perl
  2. use List::Util qw (sum);
  3. use strict;
  4. use warnings;
  5. use diagnostics;
  6.  
  7. my $chr;
  8. print "\nExtrayendo ...\n\n";
  9. $chr = "prueba";
  10. print $chr."\n";
  11. print "\nFinalizado.";
Coloreado en 0.002 segundos, usando GeSHi 1.0.8.4
gorkalinux
Perlero nuevo
Perlero nuevo
 
Mensajes: 9
Registrado: 2009-04-14 02:23 @141

Publicidad

Re: system no me imprime en php

Notapor gorkalinux » 2009-10-21 08:58 @415

Me auto-respondo.

Bastaba con llamar a mi script con './prueba.pl'

¡Despistes!
gorkalinux
Perlero nuevo
Perlero nuevo
 
Mensajes: 9
Registrado: 2009-04-14 02:23 @141

Re: system() no me imprime en PHP

Notapor explorer » 2009-10-25 05:12 @258

¿Mezclar código PHP y Perl?

Sería más claro, rápido y barato (mantenible) usar solo Perl... :)
JF^D Perl programming & Raku programming. Grupo en Telegram: https://t.me/Perl_ES
Avatar de Usuario
explorer
Administrador
Administrador
 
Mensajes: 14480
Registrado: 2005-07-24 18:12 @800
Ubicación: Valladolid, España


Volver a Básico

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 39 invitados