aMule Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're back! (IN POG FORM)

Author Topic: amulecmd scripting help requested  (Read 1600 times)

westerberg

  • Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 1
amulecmd scripting help requested
« on: September 13, 2007, 11:55:38 PM »

I have a long list of songs (artist and title) stored in a text file.
I want to write a script using amulecmd that will search for and enque these songs.
Here is what I have:
Code: [Select]
#! /bin/bash

#change to music directory which also contains list of song file
cd /home/james/MY_MUSIC

while read line; do
     
     #do a local search for first song
     amulecmd -P password -c "connect ed2k" -c "search local $line"

     #wait a few seconds for search to complete
     sleep 5s

     #redirect output of "results" command to temporary file
     amulecmd -P password -c "results" > temp.txt

     #Filter undesirable/non-music files and select file with most sources and redirect output to file
     awk 'BEGIN{high=0}/^[[:digit:]]/&&!/exe/&&!/zip/{if($NF>high){high=$NF;winner=$0}}END{print winner}' temp.txt >> outcome.txt

     #Get number of desired file
     number=`tail -1 outcome.txt | cut -d '.' -f1`

     #Attempt to download desired file. (This is where the script fails)
     amulecmd -P password -c "connect ed2k" -c "download $number"

done < /home/james/MY_MUSIC/song_list.txt

When the script gets to the download command, the output is
Quote
Invalid argument.
Type 'help download' to get more help.
even though I can see that the argument is a number and so should be valid.

Does anyone know how to get around this or know of a better way to accomplish what I am trying to do?
Logged

bainos

  • Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 3
Re: amulecmd scripting help requested
« Reply #1 on: February 07, 2008, 10:50:49 PM »

hi all

I have the same problem simply writing " amulecmd -c 'download 3' " in the prompt.. (the number doesnt matter :P)

I think that this happends beause the "-c" take a string as argument, while the command "download" needs a number ..

but I don't know...

I searched the forum but i did not found an answer..

did anybody solve this problem?

thanks in advance, sorry for my english..

bainos
Logged

bainos

  • Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 3
problem with amulecmd -c "download <number>"
« Reply #2 on: February 11, 2008, 03:45:13 PM »

hi all!
I noticed this:

I run amulecmd, than I search something.
In another console I run 'amulecmd -c "results"'.
 Than if I run 'download 3' from amulecmd prompt, it gives me the error:

Invalid argument.
Type 'help download' to get more help.

So maybe the problem is that the download command needs the results command to be run before..

sorry for my english...

can this be considered a bug?

it si very comfortable to use 'amulecmd -c' so any any answer will be apreciated!!!

regards

 bainos
Logged

zeroeth

  • Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 1
Re: amulecmd scripting help requested
« Reply #3 on: April 28, 2008, 11:45:46 PM »

Same issue here.  I do think that westerbeg is on to something.  This is also a problem if you use the amulecmd line without doing "results" first.  I don't think this is a problem with it being a string. 

For some reason the command doesn't become valid until you use the "results" command when using the amulecmd command line.  But when using amulecmd -c it seems to never become valid even if you use "results".

 Of course when you do use amulecmd -c it exits the amule command line right after the command get executed which would explain both "amulecmd -c download" and trying to use "download" right after you gets into the amule command line without using "results" first.  Any thoughts on a workaround?
« Last Edit: April 28, 2008, 11:56:34 PM by zeroeth »
Logged

GonoszTopi

  • The current man in charge of most things.
  • Administrator
  • Hero Member
  • *****
  • Karma: 165
  • Offline Offline
  • Posts: 2722
Re: amulecmd scripting help requested
« Reply #4 on: April 29, 2008, 10:53:59 PM »

Now:
1) amulecmd does not remember anything between sessions.
2) The download command needs a search result list from which it can find out the actual file data to be downloaded
3) amulecmd -c can only execute one command.
4) only one -c command is excuted even if more was given on the command line

In the future, possibly:
1) amulecmd will need to have something searched before the results command (in the same session)
2) amulecmd -c may be extended to allow executing more than one command sequentially (e.g. 'amulecmd -c "results; download 3"')
3) multiple -c commands may be allowed

Possible workaround for now:
Create an input file for amulecmd and feed it as standard input.

Code: [Select]
cmdfile=amulecmd.cmd

# make sure it is empty
echo > $cmdfile

# now fill it with commands
echo results >> $cmdfile
echo download 3 >> $cmdfile

# we must quit amulecmd
echo quit >> $cmdfile

# now run amulecmd
amulecmd < $cmdfile

You may of course edit the command list and add appropriate command-line parameters to the above amulecmd command. This script is just showing the idea how the current limitations of amulecmd may be worked around.
Logged
concordia cum veritate