DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2009-01-21 15:31:25

Marijom
Member
From: Sweden
Registered: 2007-07-06
Posts: 54

Help needed "Syntax error: Bad substitution"

Filename=${Filename:1:1}

What am i doing wrong

Offline

 

#2 2009-01-21 16:23:44

fonz
Member / Developer
From: Berlin
Registered: 2007-02-06
Posts: 1716
Website

Re: Help needed "Syntax error: Bad substitution"

Marijom wrote:

What am i doing wrong

wrong shell. /bin/sh doesn't support this.

Offline

 

#3 2009-01-31 22:34:42

Marijom
Member
From: Sweden
Registered: 2007-07-06
Posts: 54

Re: Help needed "Syntax error: Bad substitution"

I'll need help removing illegal character from filename.

I'm downloading files from a digital receiver (Topfield) thrue a wireless connection.
the filename has control characters and other illegal signs.



killall lftp
lftp -c 'open -e "mget -c -E -O  /mnt/HD_a2/AV-Media/Topfield/tmp *.rec" 192.168.0.2:/DataFiles/Xfer'

for file in /mnt/HD_a2/AV-Media/Topfield/tmp/*.rec
do
   Path=${file%/*}
   Path=${Path%/*}
   tmpFilename=${file##*/}
   schar=`expr "$tmpFilename" : '\(.\)'`
   tmpFilename=${tmpFilename#$schar}
   Filename=""
   
   while [ "$schar" != "" ]
   do
    #tmptest=`expr "$schar" : '\([[:alnum:][:blank:]._-]\)'`
    #if [ "$tmptest" != "" ]
    if [ "`expr "$schar" : '\([[:alnum:][:blank:]._-]\)'`" != "" ]
    then
       Filename="$Filename$schar"
    else
       Filename="$Filename""_"
    fi       
    
    schar=`expr "$tmpFilename" : '\(.\)'`
    tmpFilename=${tmpFilename#$schar}
  done
  Filename="$Path/$Filename"
  mv "$file" "$Filename"
  chmod a+rw -v "$Filename"
  echo $Filename
done

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB