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 Sat 20 Dec 2014, 00:00
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Get results on different lines
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [4 Posts]  
Author Message
ASRI éducation


Joined: 09 May 2009
Posts: 2648
Location: France

PostPosted: Wed 15 Oct 2014, 23:54    Post subject:  Get results on different lines
Subject description: Script to list content of folders on reposit
 

Hello
I worked for several days on a script (POU), but I'm stuck on a detail.
I need your help!

Current script:
Code:
#!/bin/sh -v
#Script to list content of folders on reposit ASRI (Sourceforge)
#20141015

URLPACKAGES="http://sourceforge.net/projects/asriedu/files/asriedu_packages/asriedu_packages_dev/spacefm/"
TempFolder="/tmp/pou"

AVPET=` curl -s -L $URLPACKAGES | awk 'BEGIN{ RS="<a href=" ; FS="\"" } {print $2 }' | grep '\.pet/download$' | sort -f -u | tr '\n' ' ' `

echo $AVPET > $TempFolder/autoupdate_lazypuppy_tmp2
sed -i 's/\/download//g' $TempFolder/autoupdate_lazypuppy_tmp2
rm $TempFolder/autoupdate_lazypuppy_tmp1

cat $TempFolder/autoupdate_lazypuppy_tmp2 |
while read ONELINE
do
ShortName="$(basename "$ONELINE")"
echo "$ShortName" >> $TempFolder/autoupdate_lazypuppy_tmp1
done

exit



Current results:
File /tmp/pou/autoupdate_lazypuppy_tmp2 => This is where I have a problem.
I want the packages listed on different lines. Currently, all gathered in one line.
Code:
http://sourceforge.net/projects/asriedu/files/asriedu_packages/asriedu_packages_dev/spacefm/spacefm_0.9.4-0_20141009_DOC.pet http://sourceforge.net/projects/asriedu/files/asriedu_packages/asriedu_packages_dev/spacefm/spacefm_0.9.4-0_20141009_NLS.pet http://sourceforge.net/projects/asriedu/files/asriedu_packages/asriedu_packages_dev/spacefm/spacefm_0.9.4-0_20141009.pet

File /tmp/pou/autoupdate_lazypuppy_tmp1 => One package is referenced, yet three are on the server.
Code:
spacefm_0.9.4-0_20141009.pet



What I want to get
File /tmp/pou/autoupdate_lazypuppy_tmp2 => packages listed on different lines
Code:
http://sourceforge.net/projects/asriedu/files/asriedu_packages/asriedu_packages_dev/spacefm/spacefm_0.9.4-0_20141009_DOC.pet
http://sourceforge.net/projects/asriedu/files/asriedu_packages/asriedu_packages_dev/spacefm/spacefm_0.9.4-0_20141009_NLS.pet
http://sourceforge.net/projects/asriedu/files/asriedu_packages/asriedu_packages_dev/spacefm/spacefm_0.9.4-0_20141009.pet

File /tmp/pou/autoupdate_lazypuppy_tmp1 => Three packages referenced
Code:
spacefm_0.9.4-0_20141009_DOC.pet
spacefm_0.9.4-0_20141009_NLS.pet
spacefm_0.9.4-0_20141009.pet


Thank you in advance.
Regards

_________________
Projet ASRI éducation => Association | Forum | Dépôt | Espace kids
Back to top
View user's profile Send private message Visit poster's website 
CatDude


Joined: 03 Jan 2007
Posts: 1497
Location: UK

PostPosted: Thu 16 Oct 2014, 03:33    Post subject:  

Hello ASRI

I made edits to two lines in your original code and it is now working OK here.

Testing it with the URLPACKAGES changed to: http://sourceforge.net/projects/asriedu/files/asriedu_packages/asriedu_packages_30x_base_puppylucid52x/
resulted in 383 files (on separate lines) in both autoupdate_lazypuppy_tmp1 and autoupdate_lazypuppy_tmp2

Code:
#!/bin/sh -v
#Script to list content of folders on reposit ASRI (Sourceforge)
#20141015

URLPACKAGES="http://sourceforge.net/projects/asriedu/files/asriedu_packages/asriedu_packages_dev/spacefm/"
TempFolder="/tmp/pou"

#AVPET=` curl -s -L $URLPACKAGES | awk 'BEGIN{ RS="<a href=" ; FS="\"" } {print $2 }' | grep '\.pet/download$' | sort -f -u | tr '\n' ' ' `
AVPET=` curl -s -L $URLPACKAGES | awk 'BEGIN{ RS="<a href=" ; FS="\"" } {print $2 }' | grep '\.pet/download$' `

#echo $AVPET > $TempFolder/autoupdate_lazypuppy_tmp2
echo $AVPET | tr " " "\n" | sort -f -u > $TempFolder/autoupdate_lazypuppy_tmp2
sed -i 's/\/download//g' $TempFolder/autoupdate_lazypuppy_tmp2
rm $TempFolder/autoupdate_lazypuppy_tmp1

cat $TempFolder/autoupdate_lazypuppy_tmp2 |
while read ONELINE
do
ShortName="$(basename "$ONELINE")"
echo "$ShortName" >> $TempFolder/autoupdate_lazypuppy_tmp1
done

exit


CatDude
.

_________________

Back to top
View user's profile Send private message 
dejan555


Joined: 30 Nov 2008
Posts: 2720
Location: Montenegro

PostPosted: Thu 16 Oct 2014, 11:56    Post subject:  

Tested CatDude's script, it worked after I created the temp dir, so I suggest adding this line too:

Code:
[ ! -d $TempFolder ] && mkdir -p $TempFolder


after:

Code:
TempFolder="/tmp/pou"

_________________
Dpup 487 | Puppy Gallery | My photo gallery | mtPaint works
Back to top
View user's profile Send private message Visit poster's website MSN Messenger 
ASRI éducation


Joined: 09 May 2009
Posts: 2648
Location: France

PostPosted: Thu 16 Oct 2014, 16:55    Post subject:  

Hello CatDude and dejan555.
A huge big thank you for your answers and your responsiveness.
It had been three long evenings this problem prevented me from continuing to improve the POU utility.
Now, everything works!
Wink

Note: In addition to POU, I will be able to use this code to create a utility for download files (pet / sfs) present on the storage servers I use.
Very Happy

_________________
Projet ASRI éducation => Association | Forum | Dépôt | Espace kids
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [4 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0658s ][ Queries: 11 (0.0040s) ][ GZIP on ]