Upper to lower case in encoded file

Hi All,

I want to change the out put of a decode file from lower to upper. i used tr command but facing issue.

set -vx
id=$(id)
dt=$(date)
store=$1
 if [[ $id = "uid=1200(raju) gid=220(raj) groups=220(raj)" ]]; then
     cd $APPL_TOP/local/bin
     cp .sqlpass.Z $$.temp.Z
     uncompress $$.temp.Z
    sed -e s/sqlpass/$$.sqlpass/ $$.temp > $$.temp1
     uudecode $$.temp1
     line=$(grep $1 $$.sqlpass)
     linlen=${#line}
     if (( $linlen > 1 ))
     then
      echo $line | tr '[:upper:]' '[:lower:]' > $line
       set $line
       printf $2
       printf $id $dt"- Login to user "$store " succesful " >> .secr.log
       rm $$.temp
       rm $$.temp1
       rm $$.sqlpass
     else
       printf "Password Not Found for user" $store
       printf $id $dt"- Password Not Found for "$store >> .secr.log
       rm $$.temp
       rm $$.temp1
       rm $$.sqlpass
       return 20
     fi
else
  printf "!!! NOT AUTHORISED !!!"
  printf $id $dt"- Atempted security access for "$store >> .secr.log
  return 20

format of encrypted password file .sqlpass.Z

raj RNSGRAJ
dev dwhdev
anil dwhanil

Now i want to change the RNSGRAJ to rnsgraj, can we use sed. please help

Error receiving -

++ tr '[:upper:]' '[:lower:]'
./secrdecode: line 22: $line: ambiguous redirect

[quote=nag_sathi;302819097]

     line=$(grep $1 $$.sqlpass)
     echo $line | tr '[:upper:]' '[:lower:]' > $line
       

I believe line is a variable you have used.
better way you just assign it to variable. You are creating a file with > sign.

try

line=$(echo $line | tr '[:upper:]' '[:lower:]')

or with awk

line=$(echo $line | awk '{print tolower($0)}')
1 Like

You do realize that when you change the content (upper to lower is changing content) you break the decompression algorithm: meaning you can no longer reliably decompress the file correctly - you get garbage.

1 Like

Hi Pamu,

Yes all the values are taken to line, i need to modify to lowercase of line, but if I modify set command giving diff results

I tried awk but throwing error

./secrdecode: line 23: unexpected EOF while looking for matching `''
./secrdecode: line 43: syntax error: unexpected end of file

Thanks

---------- Post updated at 09:36 AM ---------- Previous update was at 09:32 AM ----------

Hi Jim,

I tried to encode and change the details in the file, but its throwing error. Due to time constraint I am trying to change after saved to the variable line.

If u have any idea please help

Thanks

Please check my previous post.

I have corrected in the script.

1 Like

Hi pamu,

Thanks a lot it working. Again Thanks a TON