Amule cmd bug : Perl script in python

Viewed 37

We can interact with amule through amulecmd CLI application. Unfortunately the command:

amulecmd -c 'download index' 

not works. The download doesn't start. https://bugs.launchpad.net/ubuntu/+source/amule/+bug/190850/comments/6 In order to make it work we must to login and run that command.

The code in Perl (see link) interact with amulecmd. The script login to amulecmd , print results, download, exit

I want to convert it in python. Perl code uses Expect Module and python the pexpect library

Perl

   #!/usr/bin/perl
   use strict;
   use Expect;
   #create an Expect object by spawning another process
   my $cmd = "amulecmd -p 45000 -P mypass";
   my $exp = Expect->spawn("$cmd",())or die "Cannot spawn $cmd: $!\n";
   #send some string there:
   $exp->send("results\n");
   $exp->send("download $ARGV[0]\n");
   $exp->send("Quit\n");
   $exp->soft_close();
   $exp->hard_close();
   exit 0;

Python

#!/usr/bin/env python3.9
import time
import sys
import pexpect

child = pexpect.spawn('amulecmd -p 45000 -P mypass')
child.sendline('results\n')
time.sleep(10)
child.sendline(f'download {sys.argv[1]}\n')
child.sendline('Quit\n')

Python script doesn't print or start any download. It works only from keyboard/Perl script. Thank you for any info

Edit : closer to the Perl script

0 Answers
Related