Operating System - HP-UX
1833038 Members
2424 Online
110049 Solutions
New Discussion

Unespected "%97" as output

 
SOLVED
Go to solution
gaudiobe
Advisor

Unespected "%97" as output

I have a script that cript my codes.

It works correctly for a lot of code but it have some problems on the codes that contain the space caracter.

This script execute a java program that cript my code.

I launch the script eith the following command:
....
Var2="ABCD XY"
/opt/java6/bin/java CriptProgr "${Var2}"
....


If I run the script I get an output like this
asdf%97oe

If I run the command by command line

Example:
# /opt/java6/bin/java CriptProgr "ABCD XY"
asdf oe
#

The second result is what I need.
But I need to have this resylt running a script and I didn't understand why I have "%97" in the result.
14 REPLIES 14
VK2COT
Honored Contributor

Re: Unespected "%97" as output

Hello,

Check the environment variables from the command line and compare them with what your script uses.

That would probably highlight some
differences (like TERM, LANG or other
variables).

Cheers,

VK2COT
VK2COT - Dusan Baljevic
Dennis Handly
Acclaimed Contributor

Re: Unespected "%97" as output

I don't see any difference in the variable vs quoted string case.
gaudiobe
Advisor

Re: Unespected "%97" as output

I tryied to set the environment variable like the shell environment variable but the result is the same.

what does it means "%97" character?

Jose Mosquera
Honored Contributor

Re: Unespected "%97" as output

Hi,

It looks like your Java program is interpreting the space as a separation of parsed fields. The use of double quotes in the definition of script-level variables behave different from command prompt. Try this inside your script:

Var2="\"ABCD XY\""

By this way we try to force to always have double quotes inside the variable Var2.

Rgds.
Dennis Handly
Acclaimed Contributor

Re: Unespected "%97" as output

>what does it means "%97" character?

I've seen that in HTML as an escape for hex 97.
gaudiobe
Advisor

Re: Unespected "%97" as output

Not working.

I bypassed the problem using sed.

opt/java6/bin/java CriptProgr "${Var2}" | sed 's/%97/ /g'

But I still didn't understand why on command line I have a result as output and I have a different result if I run it inside the script.

Another things that I would like to understand is why "%97" appear inside the output and what it means.

Regards,
BG
Jose Mosquera
Honored Contributor

Re: Unespected "%97" as output

Hi again,

I guess that %97 code is not produced by your script, it is an output from Java execution.

Try execute this from your promt to check if obtains the same script behavior:
#/opt/java6/bin/java CriptProgr ABCD XY

Rgds.
gaudiobe
Advisor

Re: Unespected "%97" as output

I tried to do the following:

CodeTest="${Var2}"
echo "CodeTest=${CodeTest}" >> ${LogFile}


If I look the output in ${LogFile} i can read the following output:
CodeTest=asdf%20oe

If I did the same thing with double quote:
CodeTest="\"${Var2}\""
echo "CodeTest=${CodeTest}" >> ${LogFile}

output:
CodeTest="asdf%20oe"




Jose Mosquera
Honored Contributor

Re: Unespected "%97" as output

Inside the script, Where Var2 value come from?
Could you show us the script content?
Dennis Handly
Acclaimed Contributor
Solution

Re: Unespected "%97" as output

>If I look the output in ${LogFile}: CodeTest=asdf%20oe

I assume you just used more or cat on ${LogFile}?

It seems you have %20 in Var2. What does this show:
echo ":$Var2:"

Where did Var2 get set?
gaudiobe
Advisor

Re: Unespected "%97" as output

# echo ":$Var2:"

:ABCD%20XY:
gaudiobe
Advisor

Re: Unespected "%97" as output

echo ":$Var2:" >> ${LogFile}

output in LogFile:
...
:ABCD%20XY:
...
Dennis Handly
Acclaimed Contributor

Re: Unespected "%97" as output

>:ABCD%20XY:

This bogus %20 is why you get that %97. So where do you set Var2? From some web page?
gaudiobe
Advisor

Re: Unespected "%97" as output

Var2 was passed to the script as parameter.
The application launch the following command:

ScriptName.sh "ABCD%20XY"

I used sed to clean the %20.

I checked and %97 is the result of:
opt/java6/bin/java CriptProgr "%20"

regards
BG