Set download folder from command line or shell variable

Users and developers helping users with generic and technical Pale Moon issues on all operating systems.

Moderator: trava90

Forum rules
This board is for technical/general usage questions and troubleshooting for the Pale Moon browser only.
Technical issues and questions not related to the Pale Moon browser should be posted in other boards!
Please keep off-topic and general discussion out of this board, thank you!
JimH44

Set download folder from command line or shell variable

Unread post by JimH44 » 2019-07-18, 00:13

Hello,
I would like to be able to launch Pale Moon from a shell script, with the URL on the command line and also something to specify where this download should go. Something like
palemoon --download-folder /data/LT/Groups/Sound_processing_win/Audacity_easy_for_sound_editing https://www.audacityteam.org/download/windows/

The operator would then jump through the website's hoops to get the file to download, then Pale Moon would save it to the folder named on the command line.
If Pale Moon looks at a shell variable for the folder to download to, this would also be OK.

Is there any way I can do this?
(This is so we can keep up-to-date a software repository on a Linux system, to help people who work in language development for speakers of minority languages around the world. You can read about our project at http://lingtransoft.info/apps/langtran For downloading easy-to-get programs, we use Ketarin, which takes a "recipe" for each program. Each recipe includes the URL, how to find the version number and how to find the download URL and where to save the file to. But some websites require human intervention to get to the download site, including magic numbers, so recipes for these programs fail.)

If you know of a different Linux web browser that would do what we want, that would also help.

Thanks,
Jim

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35597
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Set download folder from command line or shell variable

Unread post by Moonchild » 2019-07-18, 10:59

You should be able to set the download folder in preferences and then use the command-line to launch the URL. I'm assuming you can just have preferences set for this setup and aren't forced to use an empty/new profile (in which case it will be more difficult and needing a mozilla.cfg)
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

Lucio Chiappetti
Astronaut
Astronaut
Posts: 660
Joined: 2014-09-01, 15:11
Location: Milan Italy

Re: Set download folder from command line or shell variable

Unread post by Lucio Chiappetti » 2019-07-18, 14:59

JimH44 wrote:
2019-07-18, 00:13
if you know of a different Linux web browser that would do what we want, that would also help.
If you are interested in retrieving http documents in line mode, most Linux distro have either or both of "curl" and "wget" commands which are "done for that" (in the past I used also lynx -dump and netscape -remote ... the -remote survived in early mozilla but I believe went away in firefox and palemoon)
The reasonable man adapts himself to the world: the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man. (G.B. Shaw)

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35597
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Set download folder from command line or shell variable

Unread post by Moonchild » 2019-07-18, 18:34

Lucio Chiappetti wrote:
2019-07-18, 14:59
"curl" and "wget" commands
I think you missed the point made that requires a full browser because for some sites page interaction is required to download documents. Command-line "getters" won't be able to do that, you'll need a full-fledged browser.
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

JimH44

Re: Set download folder from command line or shell variable

Unread post by JimH44 » 2019-07-23, 07:00

Thanks for your quick responses with comments and suggestions.
Yes, wget and similar programs won't do the job, I think, because a human needs to interact with some sites. For the simpler sites we are already using Ketarin successfully.

I found two promising solutions, but there are still problems. I was trying to resolve these before replying, but no success yet.

Netsurf has a command-line option "--downloads-directory", but the browser itself is a very cut-down one, and doesn't handle frames properly.

iMacros has a function "ONDOWNLOAD" which takes an argument for the folder to download to, but doesn't seem to pay attention to it reliably. Perhaps I didn't use it properly. I'll try again, and let you know if I win :-)

User avatar
therube
Board Warrior
Board Warrior
Posts: 1651
Joined: 2018-06-08, 17:02

Re: Set download folder from command line or shell variable

Unread post by therube » 2019-07-23, 13:08

Make modifications to a user.js file prior to calling Pale Moon.

user.js:

Code: Select all

user_pref("browser.download.lastDir", "C:\\out");
startup_script.bat:

Code: Select all

sed -e  "s/\s.*"/"\/data\/LT\/Groups\/Sound_processing_win\/Audacity_easy_for_sound_editing"  >  user.js.new
mv  user.js.new  user.js
palemoon.exe  www.lynyrd_skynyrd.com/mp3/

(Not sure if browser.download.lastDir is the correct Pref you'll need, or it is the only Pref needed.)

JimH44

Re: Set download folder from command line or shell variable

Unread post by JimH44 » 2019-07-26, 07:36

Thanks, therube, for your suggestion.

I made a new profile for this script, and my script now uses it with the browser and the -P option.
I experimented with browser.download.ThisAndThat but found it hard to get them to work properly, so I went to this:
  • * In the private profile for this script, set the download folder to /data/LT/tmpDownload
    * User downloads to this folder
    * Script moves the only file in that folder to the desired destination
That works well, and should not be affected if the behaviour of the browser.download items changes in future.

Thanks again,
Jim

Locked