• Publicidad

Ayuda con comando system()

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

Ayuda con comando system()

Notapor BigBear » 2011-11-19 08:55 @413

Tengo el siguiente código:
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. #!usr/bin/perl
  2. #GoogleHack 0.3
  3. #By Doddy H
  4.  
  5. use Tk;
  6. use Tk::PNG;
  7.  
  8. my $ventana = MainWindow->new();
  9. $ventana->title("GoogleHack 0.3 By Doddy H");
  10. $ventana->geometry("370x300+20+20");
  11. $ventana->resizable(0,0);
  12.  
  13. $ventana->Label(-font=>"Impact1",-text=>"String : ")->place(-x=>20,-y=>20);
  14. my $v = $ventana->Entry(-text=>"Test",-width=>"31")->place(-x=>80,-y=>23);
  15. $ventana->Button(-width=>"10",-text=>"Load",-command=>\&now)->place(-x=>278,-y=>23);
  16.  
  17. $ventana->Label(-text=>"Options",-font=>"Impact1")->place(-x=>140,-y=>70);
  18.  
  19. $ventana->Radiobutton(-text =>"Music", -value => "music",-variable=> \$op)->place(-x=>140,-y=>130);
  20. $ventana->Radiobutton(-text =>"Programs", -value => "programs",-variable=> \$op)->place(-x=>140,-y=>160);
  21. $ventana->Radiobutton(-text =>"Book", -value => "book",-variable=> \$op)->place(-x=>140,-y=>190);
  22. $ventana->Radiobutton(-text =>"Videos", -value => "videos",-variable=> \$op)->place(-x=>140,-y=>220);
  23. $ventana->Radiobutton(-text =>"Torrent", -value => "torrent",-variable=> \$op)->place(-x=>140,-y=>250);
  24.  
  25. MainLoop;
  26.  
  27. sub now {
  28.  
  29. my $test = $v->get;
  30. my $link;
  31.  
  32. if ($op eq "music") {
  33. $link = '-inurl:(htm|html|php) intitle:"index of" +"last modified" +"parent directory" +description +size +(.mp3|.wma|.ogg) "'.$test.'"';
  34. }
  35. elsif ($op eq "programs") {
  36. $link = '-inurl:(htm|html|php) intitle:"index of" +"last modified" +"parent directory" +description +size +(.exe|.zip|.ddl) "'.$test.'"';
  37. }
  38. elsif ($op eq "book") {
  39. $link = '-inurl:(htm|html|php) intitle:"index of" +"last modified" +"parent directory" +description +size +(.txt|.pps|.lit|.odt|.doc|.rtf|.zip|.rar|.pdf|.chm) "'.$test.'"';
  40. }
  41. elsif ($op eq "videos") {
  42. $link = '-inurl:(htm|html|php) intitle:"index of" +"last modified" +"parent directory" +description +size +(.mpg|.avi|.flv|.wmv|.di) "'.$test.'"';
  43. }
  44. elsif ($op eq "torrent") {
  45. $link = "$test filetype:torrent";
  46. } else {
  47. $link = "como aprender a escribir";
  48. }
  49. chomp $link;
  50. my $final = "http://www.google.com.ar/search?q=".$link;
  51. system("start $final");
  52. }
  53.  
  54. # The End ?
Coloreado en 0.004 segundos, usando GeSHi 1.0.8.4


El cual tiene que cargar una página mediante el comando start pero cuando se tiene que cargar parece que tiene un error con la variable string porque aparece error:

Sintáxis: [ Descargar ] [ Ocultar ]
Using text Syntax Highlighting
"html" no se reconoce como un comando interno o externo,
programa o archivo por lotes ejecutable.
Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4
BigBear
Perlero frecuente
Perlero frecuente
 
Mensajes: 981
Registrado: 2009-03-01 18:39 @818

Publicidad

Re: Ayuda con comando system()

Notapor explorer » 2011-11-19 10:36 @483

¿Y sabes cómo es lo que mandas a start?

Yo pondría un print del comando entero, justo antes de la línea 51, para saber qué comando voy a ejecutar con system().

El mensaje de error es del programa línea de comandos, no de Perl.

Apuesto a que tendrás que poner el argumento de start entre comillas dobles, debido a la presencia de caracteres "extraños" para el cmd.
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 21 invitados

cron