Sponsored Content
Full Discussion: Space in PATH variable
Top Forums UNIX for Beginners Questions & Answers Space in PATH variable Post 303000036 by bdby on Monday 3rd of July 2017 09:37:17 AM
Old 07-03-2017
Space in PATH variable

Hi All,
I did a review of some threads to see if someone had come across this problem.

My system is an oracle virtual box solaris 10 installed on a windows 10 system.

Right now I am learning scripting and am just playing with the env variables.

I am trying to update the PATH to read from the oratab file and use it.

My problem: The result I get is not quite right in the little bash statement I had written. My new exported $PATH is echo'd and a space appears between the root path and the oracle path.

My oratab in /var/opt/oracle/oratab reads the following:
Code:
  
 SGCD:/export/home/oracle/app/oracle/product/12.1.0/dbhome_2:N

Since my oracle profile reads ..../dbhome_1 I changed the "1" to a "2" in the oratab file here so as not to get both confused and to see which one is
actually getting copied. I am just learning this bash scripting.

The oracle env path is the following at the env cmd:
Code:
  
 PATH=/usr/bin:/bin:/export/home/oracle/app/oracle/product/12.1.0/dbhome_1/b

in and I am using the following command to cut it from the oratab file:
Code:
 
 ORACLE_HOME=`cat /var/opt/oracle/oratab|grep -v "^#"|cut -d ':' -f2`

output:
Code:
 /export/home/oracle/app/oracle/product/12.1.0/dbhome_2

The result I get is not quite right in the little bash statement I had written.

My new exported $PATH (PATH=/usr/sbin/usr/bin:$ORACLE_HOME/bin) is echo'd and a space appears between the root path and the oracle path right afterthe colon.

output:
Code:
 
 echo $PATH

 /usr/bin:/usr/sbin: /export/home/oracle/app/oracle/product/12.1.0/dbhome_2/bin

For the life of me I cannot figure out why this space appears above because it does not allow for other sql commands to be found and executed in my script.

Eventually i will add this to a loop statement to go thru the entire oratab file.

Any help would be appreciated.

Thanks in advance.

Last edited by rbatte1; 07-04-2017 at 12:32 PM.. Reason: code tags...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sed variable substitution when variable constructed of a directory path

Hello, i have another sed question.. I'm trying to do variable substition with sed and i'm running into a problem. my var1 is a string constructed like this: filename1 filerev1 filepath1 my var2 is another string constructed like this: filename2 filerev2 filepath2 when i do... (2 Replies)
Discussion started by: alrinno
2 Replies

2. Shell Programming and Scripting

Problems with Space at path

Hi everyone, I create script for seaching count of differrent file types at my FS. My script: #! /bin/sh #OLD_IFS=$IFS #export IFS=$(echo "\n\t ") echo "Wait a minute... Seaching is performed" d=0;b=0;c=0;p=0;s=0;l=0;f=0 non=0 for fl in $(find /opt/google/picasa/3.0/wine/drive_c... (8 Replies)
Discussion started by: babi4
8 Replies

3. Shell Programming and Scripting

sftp how to deal with space in path to dir?

OK I am trying to use something similar to this: #!/bin/sh echo "OK, starting now..." sftp -b /dev/fd/0 user@remotehost <<EOF cd pub ascii put filename.txt bye EOF only difference is the dir I need to cd to has a space in it like this /Import/Server/Prospect File ,... (3 Replies)
Discussion started by: NewSolarisAdmin
3 Replies

4. Shell Programming and Scripting

Need to execute a command on a path with a space in it...

Hello, I need to execute the following command in a script: /usr/bin/ssh 205.21.1.1 vmware-cmd -v /home/virtual machines//Machine.vmx"createsnapshot Weekly_Backup >/dev/null 2>&1 The problem is that there is a space between virtual and machines and when I run the script I get no such... (2 Replies)
Discussion started by: mojoman
2 Replies

5. Shell Programming and Scripting

remove a path from PATH environment variable

Hi I need a script which will remove a path from PATH environment variable. For example $echo PATH /usr/local/bin:/usr/bin:test/rmve:/usr/games $echo rmv test/rmve Here I need a shell script which will remove rmv path (test/rmve) from PATH... (9 Replies)
Discussion started by: madhu84
9 Replies

6. Shell Programming and Scripting

one liner to extract path from PATH variable

Hi, Could anyone help me in writing a single line code by either using (sed, awk, perl or whatever) to extract a specific path from the PATH environment variable? for eg: suppose the PATH is being set as follows PATH=/usr/bin/:/usr/local/bin:/bin:/usr/sbin:/usr/bin/java:/usr/bin/perl3.4 ... (2 Replies)
Discussion started by: royalibrahim
2 Replies

7. Shell Programming and Scripting

Appending a path in user's PATH variable

Hello Folks, I want to append a path in user's PATH variable which should be available in current session. Background Numerous persons will run a utility. Aim is to add the absolute path of the utility the first time it runs so that next runs have the PATH in env & users can directly run... (6 Replies)
Discussion started by: vibhor_agarwali
6 Replies

8. Shell Programming and Scripting

Path a variable to sed that includes a path

Hi I'm trying to select text between two lines, I'm using sed to to this, but I need to pass variables to it. For example start="BEGIN /home/mavkoup/data" end="END" sed -n -e '/${start}/,/${end}/g' doesn't work. I've tried double quotes as well. I think there's a problem with the / in the... (4 Replies)
Discussion started by: mavkoup
4 Replies

9. Shell Programming and Scripting

Setting path variable with a space.

Hi I am using MKS Toolkit c shell. I am trying to set a path variable something like c:/Program Files/blah/blah so set path=(c:/Program Files/blah/blah) this, however, does not work as it splits this thing up into 'c:/Program' and 'Files/blah/blah'. Does anyone have any ideas on... (9 Replies)
Discussion started by: vas28r13
9 Replies

10. UNIX for Dummies Questions & Answers

Find command fails when a space is in the directory path variable

I have a script like this running under OS X 10.8. The problem arises when the find command encounters a space in the path name. I need the "dir" variable as I'll be extending the script to more general use. #!/bin/bash CFS=$IFS IFS=$(echo) set dir = "/Users/apta/Library/Mail\... (3 Replies)
Discussion started by: apta
3 Replies
All times are GMT -4. The time now is 11:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy