Korn Shell Variable values difference


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Korn Shell Variable values difference
# 1  
Old 12-25-2008
Korn Shell Variable values difference

I am using two shell scripts a.ksh and b.ksh

a.ksh
1. Sets the value
+++++++++++++++++
export USER1=abcd1
export PASSWORD=xyz
+++++++++++++++++

b.ksh
2. Second scripts calls sctipt a.ksh and uses the values set in a.ksh and pass to an executable demo
++++++++++++++++++++++++++++++++++++++
. /local/home/Scripts/a.ksh
echo $USER1
echo $PASSWORD
demo -user "${USER1}" -password "${PASSWORD}"
++++++++++++++++++++++++++++++++++++++

Result
demo -user $'abcd1\r' -password $'xyz\r'

Problem is echo $USER1 and $PASSWORD both shows correct value as "abcd1" and "xyz",but when passed to demo executable it shows $'abcd1\r'. How to avoid these values when passed to external application.

K
# 2  
Old 12-26-2008
Why do you think that the parameters are passed to the external program like this? Could you post the output of the following command:

Code:
ksh -xv ./b.ksh

# 3  
Old 12-27-2008
Quote:
Originally Posted by kunalseth
I am using two shell scripts a.ksh and b.ksh

a.ksh
1. Sets the value
+++++++++++++++++
export USER1=abcd1
export PASSWORD=xyz
+++++++++++++++++

b.ksh
2. Second scripts calls sctipt a.ksh and uses the values set in a.ksh and pass to an executable demo
++++++++++++++++++++++++++++++++++++++
. /local/home/Scripts/a.ksh

Please put code inside [code] tags.
Quote:
echo $USER1
echo $PASSWORD
demo -user "${USER1}" -password "${PASSWORD}"
++++++++++++++++++++++++++++++++++++++

Result
demo -user $'abcd1\r' -password $'xyz\r'

Problem is echo $USER1 and $PASSWORD both shows correct value as "abcd1" and "xyz",but when passed to demo executable it shows $'abcd1\r'. How to avoid these values when passed to external application.

Did you edit a.ksh on a Windows box? When you do that, you must remove the carriage returns from the file before using it as a shell script.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to import a variable Used in Another Korn Shell Script?

Hi I am using two shell scripts which are running on the system simultaneously. And in one of the script i am exporting an Integer Variable. Now i want to use the variable in another script. But i cannot run the first script in the second as the first script has many other functions which... (3 Replies)
Discussion started by: Ajesh
3 Replies

2. Shell Programming and Scripting

Pass values to case statement in a function korn shell

I'm in the process of writng a function that consists of a case statement is there a way of calling the function and passing a value to it? ie function1 () { case opt1 do ..... opt2 do..... esac } function opt1 I'm aware the syntax is not correct, but you get the general idea. (1 Reply)
Discussion started by: squrcles
1 Replies

3. Shell Programming and Scripting

overcome unwanted input values in korn shell

Hi All, we are doing automation for installation of oracle, a) ORACLE_HOME_NAME b) ORACLE_HOME above are the argument we need to pass during the script execution, while doing this someone issue the value like ORACLE_HOME=/optware/oracle/11g;rm -rf /optware/oracle/10g its removing... (1 Reply)
Discussion started by: kamauv234
1 Replies

4. Programming

create a spool file based on values passed from korn shell to sql script

this is my issue. 4 parameters are passed from korn shell to sql script. parameter_1= varchar2 datatype or no value entered my user. parameter_2= number datatype or no value entered my user. parameter_3= number datatype or no value entered my user. parameter_4= number datatype or no... (5 Replies)
Discussion started by: megha2525
5 Replies

5. Shell Programming and Scripting

Korn shell program to parse CSV text file and insert values into Oracle database

Enclosed is comma separated text file. I need to write a korn shell program that will parse the text file and insert the values into Oracle database. I need to write the korn shell program on Red Hat Enterprise Linux server. Oracle database is 10g. (15 Replies)
Discussion started by: shellguy
15 Replies

6. Programming

How to refer to variable (korn shell)?

Hi I have the following block of code in korn shell and don't now how to refer to variable `print variable1.$dvd` ? --- integer dvd=4 integer number=0 while (( dvd!=0 )) do print "Iteracja numer : $dvd" print "$_" #it refers to $dvd var but want to refer... (3 Replies)
Discussion started by: presul
3 Replies

7. Shell Programming and Scripting

Setting variable for query using iSql / Korn Shell

Hi All- First time using iSql. I have 4 query files - some have more than 1 line of sql statements After a bit of research it appears I can just use the -i command and specify the input file. Questions: Does it matter that there are multiple queries in each file? Do I need to have... (3 Replies)
Discussion started by: Cailet
3 Replies

8. Shell Programming and Scripting

compound variable in korn shell

in a text " Korn Shell Unix programming Manual 3° Edition" i have found this sintax to declare a compoud variable: variable=( fild1 fild1 ) but this sintax in ksh and sh (HP-UNIX) not work... why?? exist another solution for this type of variable ??? (5 Replies)
Discussion started by: ZINGARO
5 Replies

9. Shell Programming and Scripting

compound variable in korn shell

in a text " Korn Shell Unix programming Manual 3° Edition" i have found this sintax to declare a compoud variable: variable=( fild1 (0 Replies)
Discussion started by: ZINGARO
0 Replies

10. Shell Programming and Scripting

Korn Shell Script - Read File & Search On Values

I am attempting to itterate through a file that has multiple lines and for each one read the entire line and use the value then to search in other files. The problem is that instead of an entire line I am getting each word in the file set as the value I am searching for. For example in File 1... (2 Replies)
Discussion started by: run_unx_novice
2 Replies
Login or Register to Ask a Question