NSLU2-Linux
view · edit · print · history

Puppy.CopyFiles History

Hide minor edits - Show changes to markup

July 27, 2007, at 10:29 PM by Robert -- Managed Hosting, Colocation and Data Center Services by victoryushchenkonashpresudent ...
February 28, 2005, at 01:37 PM by peteru --
Added lines 31-34:
Added line 83:
Added lines 107-108:
Added line 180:
Changed line 238 from:
to:
February 28, 2005, at 01:34 PM by peteru --
Changed lines 31-33 from:

area=d
ld=0
lf=0\\

to:
 area=d
 ld=0
 lf=0
Changed lines 35-36 from:

while [ $# != 0 ] do

to:
 while [ $# != 0 ]
 do
Changed line 53 from:

done

to:
 done
Changed line 55 from:

case $area in

to:
 case $area in
Changed line 59 from:

esac

to:
 esac
Changed line 61 from:

path=`echo $path | tr / \\`

to:
 path=`echo $path | tr / \\`
Changed lines 63-64 from:

if [ $ld -eq 1 ] then

to:
 if [ $ld -eq 1 ]
 then
Changed line 66 from:

fi

to:
 fi
Changed lines 68-69 from:

if [ $lf -eq 1 ] then

to:
 if [ $lf -eq 1 ]
 then
Changed line 71 from:

fi

to:
 fi
Changed lines 73-74 from:

if [ $ld -eq 0 -a $lf -eq 0 ] then

to:
 if [ $ld -eq 0 -a $lf -eq 0 ]
 then
Changed line 76 from:

fi

to:
 fi
Changed line 78 from:

exit

to:
 exit
Changed lines 102-111 from:

#!/bin/sh
#
# Copy files from Toppy to somewhere
#
area=d
sdir=
nme=
tgt=
fst=1
tmp=/tmp/names\\

to:
 #!/bin/sh
#
# Copy files from Toppy to somewhere
#
area=d
sdir=
nme=
tgt=
fst=1
tmp=/tmp/names\\
Changed lines 113-114 from:

while [ $# != 0 ] do

to:
 while [ $# != 0 ]
 do
Changed line 134 from:

done

to:
 done
Changed line 136 from:

# I dont want to fill my flash drive if I forgot to mount a smb fs.

to:
 # I dont want to fill my flash drive if I forgot to mount a smb fs.
Changed lines 138-139 from:

if [ "$tgt" != "" ] && [ -d $tgt ] then

to:
 if [ "$tgt" != "" ] && [ -d $tgt ]
 then
Changed line 155 from:

else

to:
 else
Changed line 171 from:

fi

to:
 fi
Changed lines 173-174 from:

if [ "$nme" = "" ] then

to:
 if [ "$nme" = ""  ]
 then
Changed lines 186-187 from:

elif [ "$nme" = "*" ] then

to:
 elif [ "$nme" = "*" ]
 then
Changed line 189 from:

fi

to:
 fi
Changed line 191 from:

case $area in

to:
 case $area in
Changed line 195 from:

esac

to:
 esac
Changed lines 197-198 from:

trap "rm -f $tmp" 0 1 2 3 cmd="pdir -a $area -f \"$sdir\" ${nme:+| grep -i \"$nme\"} > $tmp"

to:
 trap "rm -f $tmp" 0 1 2 3
 cmd="pdir -a $area -f \"$sdir\" ${nme:+| grep -i \"$nme\"} > $tmp"
Changed line 200 from:

#echo $cmd

to:
 #echo $cmd
Changed line 202 from:

eval $cmd

to:
 eval $cmd
Changed lines 204-205 from:

if [ ! -s $tmp ] then

to:
 if [ ! -s $tmp ]
 then
Changed line 208 from:

fi

to:
 fi
Changed line 210 from:

3<$tmp

to:
 3<$tmp
Changed line 212 from:

while

to:
 while
Changed line 214 from:

do

to:
 do
Changed line 216 from:

# cmd="puppy ${fst:--t} -c get \"$area\\$sdir\\$file\" \"$tgt/$file\""\\

to:
 #       cmd="puppy ${fst:--t} -c get \"$area\\$sdir\\$file\" \"$tgt/$file\""\\
Changed line 227 from:

done

to:
 done
Changed line 229 from:

exit

to:
 exit
Added line 238:
February 28, 2005, at 01:25 PM by peteru --
Changed line 9 from:

Files on the toppy are in ProgramFiles?, DataFiles? or MP3? so I called these AREAS and gave them shortcuts: p, d & m.

to:

Files on the toppy are in ProgramFiles, DataFiles or MP3 so I called these AREAS and gave them shortcuts: p, d & m.

Changed line 23 from:

dir[/dir...]There are also sub-directories and they can have sub-directories: So you can specify movie or drama/AllSaints?.

to:

dir[/dir...]There are also sub-directories and they can have sub-directories: So you can specify movie or drama/AllSaints.

Changed lines 56-58 from:
        d|D)    area=DataFiles?;;
        p|P)    area=ProgramFiles?;;
        m|M)    area=MP3?;;
to:
        d|D)    area=DataFiles;;
        p|P)    area=ProgramFiles;;
        m|M)    area=MP3;;
Changed line 92 from:

-s sub directory path (case sensitive) eg drama/AllSaints?.

to:

-s sub directory path (case sensitive) eg drama/AllSaints.

Changed line 99 from:

If no options are specified, then all files in the DataFiles? area are transferred to the target directory.

to:

If no options are specified, then all files in the DataFiles area are transferred to the target directory.

Changed lines 192-194 from:
        d|D)    area=DataFiles?;;
        p|P)    area=ProgramFiles?;;
        m|M)    area=MP3?;;
to:
        d|D)    area=DataFiles;;
        p|P)    area=ProgramFiles;;
        m|M)    area=MP3;;
February 28, 2005, at 12:45 PM by tonymy01 --
Changed line 31 from:

[@area=d\\

to:

area=d\\

Changed line 78 from:

exit@]

to:

exit

February 28, 2005, at 12:45 PM by tonymy01 --
Changed line 31 from:

area=d\\

to:

[@area=d\\

Changed line 78 from:

exit

to:

exit@]

February 28, 2005, at 12:07 PM by Malcolm --
Changed lines 31-33 from:

area=d ld=0 lf=0

to:

area=d
ld=0
lf=0\\

Added line 77:
Added line 228:
February 28, 2005, at 12:05 PM by Malcolm --
Changed lines 198-200 from:
  1. echo $cmd
to:

#echo $cmd

Added line 214:
Added line 216:
February 28, 2005, at 12:03 PM by Malcolm --
Changed lines 101-104 from:

#!/bin/sh\\ #\\ # Copy files from Toppy to somewhere\\ #\\

to:

#!/bin/sh
#
# Copy files from Toppy to somewhere
#\\

Changed line 212 from:
  1. cmd="puppy ${fst:--t} -c get \"$area\\$sdir\\$file\" \"$tgt/$file\""
to:

# cmd="puppy ${fst:--t} -c get \"$area\\$sdir\\$file\" \"$tgt/$file\""\\

Changed line 224 from:

=]

to:
February 28, 2005, at 12:01 PM by Malcolm --
Changed lines 101-110 from:

#!/bin/sh #

  1. Copy files from Toppy to somewhere

area=d sdir= nme= tgt= fst=1 tmp=/tmp/names

to:

#!/bin/sh\\ #\\ # Copy files from Toppy to somewhere\\ #\\ area=d
sdir=
nme=
tgt=
fst=1
tmp=/tmp/names\\

February 28, 2005, at 12:00 PM by Malcolm --
Changed lines 101-111 from:

[=

  1. !/bin/sh
    #
    # Copy files from Toppy to somewhere
    #
    area=d
    sdir=
    nme=
    tgt=
    fst=1
    tmp=/tmp/names\\
to:

#!/bin/sh #

  1. Copy files from Toppy to somewhere

area=d sdir= nme= tgt= fst=1 tmp=/tmp/names

Changed line 135 from:
  1. I dont want to fill my flash drive if I forgot to mount a smb fs.
to:

# I dont want to fill my flash drive if I forgot to mount a smb fs.

February 28, 2005, at 11:58 AM by Malcolm --
Changed lines 102-111 from:
  1. !/bin/sh
  2. Copy files from Toppy to somewhere

area=d sdir= nme= tgt= fst=1 tmp=/tmp/names

to:
  1. !/bin/sh
    #
    # Copy files from Toppy to somewhere
    #
    area=d
    sdir=
    nme=
    tgt=
    fst=1
    tmp=/tmp/names\\
February 28, 2005, at 11:57 AM by Malcolm --
Deleted line 18:
Deleted line 20:
Deleted line 22:
Added line 77:

exit

Deleted line 88:
Deleted line 90:
Deleted line 92:
Deleted line 94:
Added line 101:

[=

Added line 225:

=]

February 28, 2005, at 11:54 AM by Malcolm --
Added lines 12-13:
Added lines 18-19:
Added lines 21-22:
Added lines 24-25:
Added line 28:
Added line 33:

Added lines 80-81:

Added lines 84-85:
Added lines 90-91:
Added lines 93-94:
Added lines 96-97:
Added line 100:
Added line 103:
Added line 106:

Added lines 230-231:

Added line 235:
Added line 238:
Added line 242:
February 28, 2005, at 11:52 AM by Malcolm --
Added line 14:
Added lines 73-74:
February 28, 2005, at 11:50 AM by Malcolm --
Changed line 12 from:

pdir [-a "area"] [-d] [-f] "dir[/dir...]"

to:

pdir [-a area] [-d] [-f] dir[/dir...]

Changed line 71 from:

pget [-t] [-a area] [-s sdir[/sdir...]] [-n name] target

to:

pget [-t] [-a area] [-s sdir[/sdir...]] [-n name] target

February 28, 2005, at 11:49 AM by Malcolm --
Changed lines 1-217 from:

Describe CopyFiles here.

to:

I wanted to transfer multiple files from my Toppy to my pc overnight. The kids complain if I use turbo mode as they lose the use of the remote.

As puppy only accepts a single file, it seemed a good idea to wrap puppy in a script. Here are 2 scripts that I use: Copy them to a directory that is is your path when you log into the slug.

Please understand that my scripting abilities are limited: feel free to offer suggestions. You should also study them as you may want to delete some of the code.

Both scripts understand -h as an option. It displays help. Files on the toppy are in ProgramFiles?, DataFiles? or MP3? so I called these AREAS and gave them shortcuts: p, d & m.

A directory listing with a difference: pdir [-a "area"] [-d] [-f] "dir[/dir...]"

-a allows you to enter an AREA. Use d, p or m for the areas listed above (-a d is the default). If you have created another high level directory then use its (case sensitive) name. -d will list only directories in sorted order -f will list only filenames in sorted order dir[/dir...]There are also sub-directories and they can have sub-directories: So you can specify movie or drama/AllSaints?.

Note: You can specify -d & -f but I dont know why you would want to.

If no options are specified, then the output from puppy is not modified.

area=d ld=0 lf=0

while [ $# != 0 ] do

        case $1 in
                -a)     area=$2; shift;;
                -a*)    area=`echo $1|sed -e 's/-a//'`;;
                -d)     ld=1;;
                -f)     lf=1;;
                -h)     echo Usage: pdir [-a [area]] [-d] [-f] [-h] [path]
                        echo -e "-a\tMain area [D]ataFiles (default) [P]rogramFiles [M]P3"
                        echo -e "-d\tList directories only"
                        echo -e "-f\tList files only"
                        echo -e "-h\tDisplay this help"
                        echo -e "path\tDirectory path to list (case sensitive) use / to separate dirs"
                        exit;;
                *)      path=$1;;
        esac

        shift

done

case $area in

        d|D)    area=DataFiles?;;
        p|P)    area=ProgramFiles?;;
        m|M)    area=MP3?;;

esac

path=`echo $path | tr / \\`

if [ $ld -eq 1 ] then

        puppy -c dir "$area\\$path" | sed -e '/^f/d' | cut -b49- | sort

fi

if [ $lf -eq 1 ] then

        puppy -c dir "$area\\$path" | sed -e '/^d/d' | cut -b49- | sort

fi

if [ $ld -eq 0 -a $lf -eq 0 ] then

        puppy -c dir "$area\\$path" | sort

fi

To retrieve multiple files: pget [-t] [-a area] [-s sdir[/sdir...]] [-n name] target -t turbo mode off -a allows you to enter an AREA. Use d, p, m for the areas listed above. If you have created another high level directory then use its (case sensitive) name. -s sub directory path (case sensitive) eg drama/AllSaints?. -n partial name (case insensitive)

target The directory to receive the toppy's files.

If no options are specified, then all files in the DataFiles? area are transferred to the target directory.

  1. !/bin/sh
  2. Copy files from Toppy to somewhere

area=d sdir= nme= tgt= fst=1 tmp=/tmp/names

while [ $# != 0 ] do

        case $1 in
                -a)     area=$2; shift;;
                -a*)    area=`echo $1|sed -e 's/-a//`;;
                -s)     sdir=$2; shift;;
                -s*)    sdir=`echo $1|sed -e 's/-s//'`;;
                -n)     nme="$2"; shift;;
                -n*)    nme=`echo $1|sed -e 's/-n//'`;;
                -t)     fst=;;
                -h)     echo "Usage: pget [-a area] [-p path] [-n partial name] target"
                        echo "-a Specify area [D]ataFiles (def), [P]rogramFiles, [M]P3 or top level dir"
                        echo "-s Specify sub directory or sub-dir path (in full using / and case sensitive)"
                        echo "-n specify part of a file name (case insensitive) \* for all files"
                        echo "-t Turbo mode off"
                        echo "-h Display this help"
                        echo target is destination directory for files
                        exit;;
                *)      tgt=$1;;
        esac
        shift

done

  1. I dont want to fill my flash drive if I forgot to mount a smb fs.

if [ "$tgt" != "" ] && [ -d $tgt ] then

        lne=`mount | grep smbfs | grep smbfs`

        if [ "$lne" = "" ]
        then
                echo Warning: No smb file systems mounted
                echo -e "Continue? \c"
                read ANS
                if [ "$ANS" = "y" -o "$ANS" = "Y" ]
                then
                        :
                else
                        echo Aborting
                        exit
                fi
        fi

else

        if [ -e $tgt ]
        then
                echo Target must be a directory.
                exit
        else
                echo -e "Create target directory $tgt? \c"
                read ANS
                if [ "$ANS" = "y" -o "$ANS" = "Y" ]
                then
                        mkdir -p $tgt
                else
                        echo Aborting
                        exit
                fi
        fi

fi

if [ "$nme" = "" ] then

        echo -e "No file name specified!"
        echo -e "Copy all files from area $area, dir $sdir? \c"
        read ANS

        if [ "$ANS" = "y" -o "$ANS" = "Y" ]
        then
                :
        else
                echo Aborting
                exit
        fi

elif [ "$nme" = "*" ] then

        nme=

fi

case $area in

        d|D)    area=DataFiles?;;
        p|P)    area=ProgramFiles?;;
        m|M)    area=MP3?;;

esac

trap "rm -f $tmp" 0 1 2 3 cmd="pdir -a $area -f \"$sdir\" ${nme:+| grep -i \"$nme\"} > $tmp"

  1. echo $cmd

eval $cmd

if [ ! -s $tmp ] then

        echo "No files to copy - check Directory and/or name (use -n \* or -n* for all files)"
        exit

fi

3<$tmp

while

        read file <&3

do

  1. cmd="puppy ${fst:--t} -c get \"$area\\$sdir\\$file\" \"$tgt/$file\"" cmd="puppy -t -c get \"$area\\$sdir\\$file\" \"$tgt/$file\"" echo $cmd eval $cmd
    if [ $? -ne 0 ] then
                puppy -c cancel
                puppy -c cancel
fi

done exit

Because I use a flash drive, I must transfer any files to another pc. So, there is some code to check if I have mounted target as a samba share (mounts are lost on reboot).

If the target does not exist, it will offer to create it.

I normally use pdir a few times to work out where things are and then use pget to copy them. The shell allows you to combine multiple statements on one line. Separate the statements by a semi-colon. eg pget -n kate /gw; pget -s movie -n red /gw transferred kate & leopold and red october to my gateway pc.

My thanks to Peteru for this neat program.

Malcolm

Bugs: Sometimes I am not sure if a message is from puppy or a problem with the script.

view · edit · print · history · Last edited by Robert.
Based on work by peteru, tonymy01, and Malcolm.
Originally by Malcolm.
Page last modified on July 27, 2007, at 10:29 PM