[Solved] reassign value to variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [Solved] reassign value to variable
# 1  
Old 08-29-2012
[Solved] reassign value to variable

Hi,
Please let me know how to reassign value to a variable.The calling script is passing parameter as HAT_DIV but I like to pass HAT DIV ( two words) to DIV parameter.These are .ksh scripts.

Code:
# access to target - (user passwd sid) must be provided.
USER=$1;                                 export USER
PASSWD=$2;                               export PASSWD
SID=$3;                                  export SID
DB=$4;                                  export PDM_DB
DIV=$5;                                  export DIV
DEPT=$6;                                 export DEPT
if [ $5 eq HAT_DIV ]; then
 DIV="HAT DIV";
fi
$ORACLE_HOME/bin/sqlplus ${USER}/${PASSWD}@${SID} >>./run_convert_${DEPT}.log <<EOC
whenever sqlerror exit 1
 execute CNVT_SUMMARY('${DB}', '${OWNER}','${DIV}','${DEPT}');
EOC
if [ $? -eq 1 ]; then
  echo "Error in the stored procedure CNVT_SUMMARY";
  echo $DIV;
  printf "%s\n" "$@";
  exit 1
fi

how parameters being passed
Code:
U CNVT_SUMMARY.ksh scott tiger testdb fashion HAT_DIV 12

This is error message.
Code:
eq: 0403-012 A test command parameter is not valid.

Thanks
Sandy

Last edited by sandy162; 08-29-2012 at 10:16 AM.. Reason: adding some more information
# 2  
Old 08-29-2012
What issues are u getting? is it not due to eq and not -eq?
# 3  
Old 08-29-2012
You don't mention which shell you are using. Assuming it's bash, the assignment seems correct, but the preceding if construct will not work. Replace the "eq" (should be -eq anyhow), which compares integers, with "==", which compares strings.
# 4  
Old 08-29-2012
Please find the updated information in my first post.
# 5  
Old 08-29-2012
Quote:
Originally Posted by sandy162
Please find the updated information in my first post.
I hope you found the answer for the error.. or else please read the man page for TEST command u fill find the solution in seconds Smilie Smilie
# 6  
Old 08-29-2012
this worked for me.
Code:
if [ "$5" = "HAT_DIV" ]; then
 DIV="HAT DIV";
fi

Thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] Assigning Shell variable

Hello, Need a small help to execute below script. #!/bin/bash . new.txt for no in 3 4 do echo $((uname_$no)) done new.txt contains uname_1="XXXXXX" uname_2="YYYYY" uname_3="ZZZZZ" ......... (6 Replies)
Discussion started by: prasanna2166
6 Replies

2. Shell Programming and Scripting

[Solved] Count characters of variable from right

My variable is something like: f="/Volumes/VERVE/MOOTON_CALL/01_shots/XX/xx0195/Projects/program/rs0195_v400001.aep" I use ${f:63:6} to call "rs0195" as characters counted from the left, but it'd be so much easier to count from the right. If ${f:95:10} counts from the left, what would... (2 Replies)
Discussion started by: scribling
2 Replies

3. Shell Programming and Scripting

[Solved] How to increment and add variable length numbers to a variable in a loop?

Hi All, I have a file which has hundred of records with fixed number of fields. In each record there is set of 8 characters which represent the duration of that activity. I want to sum up the duration present in all the records for a report. The problem is the duration changes per record so I... (5 Replies)
Discussion started by: danish0909
5 Replies

4. Shell Programming and Scripting

[Solved] cp command with dollar variable in ksh

hi, I have been trying to acheive the following task for a while now, but failed.. Need help, experts please help! This is what I am trying to do: - I am writing to a flat file the name of the source to be copied and the destination path as to where it is to be copied to. Sample flat file:... (7 Replies)
Discussion started by: abdulhusein
7 Replies

5. Solaris

reassign zfs pool lun

I have a branded zone txdjintra that utilizes a pool named Pool_djintra that is no longer required. There is a 150 Gig Lun assigned to the pool that I need to reassign to another branded zone txpsrsrv07 with a pool named Pool_txpsrsrv07 on the same sun blade. What is the process to do this? ... (0 Replies)
Discussion started by: jeffsr
0 Replies

6. Shell Programming and Scripting

storing a value from another file as a variable[solved]

Hi all, im having snags creating a variable which uses commands like cut and grep. In the instance below im simply trying to take a value from another file and assign it to a variable. When i do this it only prints the $a rather than the actual value. I know its simple but does anyone have any... (1 Reply)
Discussion started by: somersetdan
1 Replies

7. UNIX for Dummies Questions & Answers

Solved: how to save an output to a variable

i want to save the output of /scripts/whoowns domain.com to a username like $user = /scripts/whoowns domain.com but I'm not sure how to do that This is inside a bash script how can I get the output of /scripts/whoowns then save that to a variable? thanks! ---------- Post updated at... (0 Replies)
Discussion started by: vanessafan99
0 Replies

8. UNIX for Dummies Questions & Answers

[Solved] Variable Name as a Prompt

Dear Members, I have an variable by name dir.If i do echo $dir i will get the path (/usr/bin/). I am writing a shell script which will prompt to enter the variable name if run.Suppose the script name is test.sh. If run test.sh it will prompt for entering variable name which is dir.Suppose... (9 Replies)
Discussion started by: sandeep_1105
9 Replies

9. Shell Programming and Scripting

Manipulating a variable using sed (solved)

Hi, My variable has value as this: tvar1="bool_risk_enabled" Boolean "true" Now I need to replace this true with false. Which is the best way to do this? Can we do this with sed command? Please help me. ---------- Post updated at 05:23 PM ---------- Previous update was at 05:00 PM... (2 Replies)
Discussion started by: pravintse
2 Replies

10. UNIX for Dummies Questions & Answers

Reassign value to a string variable

hi to all, i have a string variable that i want to reassign a new value in it through a script and i am having some trouble. i write the following if statement: if then $checkupd="lastupdate = " fi in this statement i check if the variable checkupd contains the word "lastupdate".... (2 Replies)
Discussion started by: omonoiatis9
2 Replies
Login or Register to Ask a Question