Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 26 Nov 2014, 21:55
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
About BK Puppy file downlaoder [SOLVED]
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count  
Author Message
Argolance


Joined: 06 Jan 2008
Posts: 1847
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Fri 30 Nov 2012, 08:38    Post_subject:  About BK Puppy file downlaoder [SOLVED]  

Hello,
Using the wget option [-O], it is possible to download a file to any chosen directory/filename. For example:
Code:
# wget http://mysite/puppylinuxstuff/picture.png -O /root/my-documents/my-pictures/filename.png

The BK script 'download_file', (which seems to be a GUI for wget) automatically downloads files to /root. I would like to be able to choose, at least, the target directory. Is there a way to do it using a command line and without having to modify the original script?
For example, I tried this but Crying or Very sad :
Code:
# download_file http://mysite/puppylinuxstuff/picture.png > /root/my-documents/my-pictures/filename.png


Thank you.
Cordialement.

_________________


Edited_time_total
Back to top
View user's profile Send_private_message Visit_website 
RSH


Joined: 05 Sep 2011
Posts: 2420
Location: Germany

PostPosted: Fri 30 Nov 2012, 11:10    Post_subject:  

Hi.

i do use wget-option --directory-prefix=$LP2BDL wherein $LP2BDL is the LazY Puppy boot directory to download the LazY Puppy sfs files from the RunScripts directly to the boot directory.

After download you can rename the downloaded file using bash command mv if needed.

RSH

_________________
LazY Puppy
RSH's DNA
SARA B.
Back to top
View user's profile Send_private_message 
sc0ttman


Joined: 16 Sep 2009
Posts: 2386
Location: UK

PostPosted: Fri 30 Nov 2012, 11:29    Post_subject:  

Save the following as 'download_progress':

the 1st option is the URL to download, the 2nd (optional) parameter is the output filename, or output dir (if it's a dir)

Code:
#!/bin/bash
# original script by technosaurus
#18012012: fixed to work on akita: no busybox, wget -c, added some translations, error checking, etc
 
#usage, cli options
{
   [ "$1" = "" ] && echo "Usage: $(basename $0) URL [output file]" && exit 1
if [ "$2" != "" ];then # add output file or dir, if given
   [ -f "$2" ] && OUTPUTFILE="-O$2"
   [ -d "$2" ] && OUTPUTFILE="-P$2"
else
   OUTPUTFILE=''
fi
export OUTPUTFILE
}
# i18n, translations
{
[ $myLANG ] || myLANG=${LANGUAGE%% *}
[ $myLANG ] || myLANG=${LANG%_*}
case $myLANG in
   de*)
      Loc_downloading_file="Download der Datei"
      Loc_download_progess="Download-Fortschritt"
      Loc_files_remaining="Dateien übrig"
      Loc_current_file_is="Aktuelle Datei ist"
      ;;
  es*)
      Loc_downloading_file="Descargar el fichero"
      Loc_download_progess="El progreso de descarga"
      Loc_files_remaining="archivos restantes"
      Loc_current_file_is="Archivo actual es"
      ;;
  fr*)
      Loc_downloading_file="Fichiers en cours de téléchargement"
      Loc_download_progess="Progression du téléchargement en cours"
      Loc_files_remaining="Fichier(s) restant(s)"
      Loc_current_file_is="Le fichier actuellement en téléchargement est"
      ;;
  nl*)
      Loc_downloading_file="Downloaden bestand"
      Loc_download_progess="Download vooruitgang"
      Loc_files_remaining="bestanden over"
      Loc_current_file_is="De huidige bestand is"
      ;;
  ru*)
      Loc_downloading_file="Загрузка файла"
      Loc_download_progess="Прогресс загрузки"
      Loc_files_remaining="файл. осталось"
      Loc_current_file_is="Текущий файл"
      ;;
   *);;
esac
}

download_progress(){ #pass a file as $1 to download with a GUI progress bar
while ([ $# -gt 0 ]) do
   LANG=C # should avoid wget returning weird values
   wget "$OUTPUTFILE" -4 -c "$1" 2>&1 | while read LINE; do
      case $LINE in
         *%*)LINE=${LINE##*..};echo ${LINE%%%*};;
      esac
   done |Xdialog --wm-class "button" --title "${Loc_downloading_file:-Downloading File}" --gauge "${Loc_download_progess:-Download progress} ($# ${Loc_files_remaining:-files remaining}.)
${Loc_current_file_is:-Current file is}:
$1" 0 0
   shift
done
}

download_progress "${1}"

_________________
Akita Linux, VLC-GTK, Pup Search, Pup File Search
Back to top
View user's profile Send_private_message 
Argolance


Joined: 06 Jan 2008
Posts: 1847
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Fri 30 Nov 2012, 12:27    Post_subject:  

Hello,
Thank you for answering...
@RSH,
Quote:
After download you can rename the downloaded file using bash command mv if needed.
I wanted to use the BK script, because it tests if file exists, has already been completely or just partially downloaded and so on, displays a progress bar instead of the classical wget urxvt window and is already 'gettexted'. I could indeed simply move/rename the downloaded /root/file but I am not sure the file is always downloaded at this place, depending (perhaps?) on the running Puppy mode (?).
Question: is the file always downloaded at this place?

@sc0ttman,
The script by technosaurus is quite interesting but doesn't make all what I am waiting for. If downloaded file already exists, windows appears quickly and closes immediately, and user don't know exactly what happens.
Else: Sorry, I could not define the output directory/filename. File is downloaded in the script directory Embarassed
For example (usage: techscript.sh URL [output file]):
Code:
# ./techscript.sh http://mysite/puppylinuxstuff/picture.png  /root/my-documents/my-pictures/filename.png

Did I miss something?

EDIT:
Quote:
he 1st option is the URL to download, the 2nd option is the output filename, or output dir (if it's a dir)
Okay, okay:
Code:
# ./techscript.sh http://mysite/puppylinuxstuff/picture.png  /root/my-documents/my-pictures/

Cordialement.

_________________

Back to top
View user's profile Send_private_message Visit_website 
Argolance


Joined: 06 Jan 2008
Posts: 1847
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Fri 30 Nov 2012, 13:21    Post_subject:  

Hello,
I found 'a' solution:
Quote:
Question: is the file always downloaded at this place?
I well noticed it was not always the same place, probably depending on the rox-filer active directory window (?)
Code:
# cd /root/my-documents/my-pictures/
# download_file http://mysite/puppylinuxstuff/picture.png

... and I find my downloaded file in /root/my-documents/my-pictures/
Cool

Thank you!
Cordialement.

_________________

Back to top
View user's profile Send_private_message Visit_website 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0671s ][ Queries: 12 (0.0037s) ][ GZIP on ]