Setting path variable with a space.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Setting path variable with a space.
# 1  
Old 07-27-2011
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
Code:
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 how to fix this issue. Perhaps some simple little hack??

Thank you!
# 2  
Old 07-27-2011
Have you tried escaping the space with a backslash? e.g.,

Code:
set path=(c:/Program\ Files/blah/blah)

# 3  
Old 07-27-2011
yes I tried that it didnt work for me...Smilie
# 4  
Old 07-27-2011
Have you tried... two backslashes? I'm serious.
# 5  
Old 07-27-2011
Ha ya I thought the same thing. The first one is ignored and the second one remains. The space is not escaped and is intepreted at a type of seperator for the next variable. I'm trying different things right now. I think there is something to do with the actual PATH vs path vd ${PATH} im not sure just trying things
# 6  
Old 07-27-2011
Are you sure that that 'path' variable is supposed to be set as an array?
This User Gave Thanks to Nitrodist For This Post:
# 7  
Old 07-27-2011
Ya I am almost positive its suppose to be set like this. But! I actually found the problem...well at least theoretically.
You were right the \ does work to espace the character it just that something is going wrong somewhere else in my script where it sources something which sets something idk i'll have to look into this.
Thanks

---------- Post updated at 03:37 PM ---------- Previous update was at 03:17 PM ----------

OKay so I figured out the problem but I do not have a solution.

Basically when you do this
Code:
set path=($path c:/Program\ Files/blah/blah)

it works completely fine, no problems.
BUT! the next time you add a path it will interpret blank spaces as a new variable start.
so if i do
Code:
set path=($path c:/doagain)

then the previous path formatting gets messed up!

please help! any ideas??
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Problem setting path to external hard drive as a variable

Hello all, I am EXTREMELY new to using bash and I have a bit of a problem: I'm trying to set up a shell script that can 1.) take one of several giant files off of an external hard drive 2.) use it as input for scripts on my laptop's hard drive ... (3 Replies)
Discussion started by: machine_spirit
3 Replies

2. UNIX for Beginners Questions & Answers

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... (9 Replies)
Discussion started by: bdby
9 Replies

3. 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

4. Shell Programming and Scripting

Understanding PATH variable setting?

I do know how we set the PATH variable- export PATH=$JAVA_HOME/bin:$PATH I'm trying to understand why we have written :$PATH in the end above statement. What is it's meaning? (2 Replies)
Discussion started by: boy18nj
2 Replies

5. Shell Programming and Scripting

awk: Eliminating white space while setting variable

Hi, I have a large flat file from host without delimiter. I'm transforming this file to a csv file using statements like # Row 03: Customer / field position 3059 +20 WOFABNAM=substr( $0, 3059, 20 ); and deleting the trailing whitespaces before and after with that sub( /^ +/, "",... (4 Replies)
Discussion started by: Celald
4 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

Error in setting PATH variable in bash shell

Hi, I am new to shell scripting.I tried adding an entry to the path variable like below export PATH=$PATH:/opt/xxx/bin But am getting an error invalid identifier /opt/xxx/bin Can someone tell me the error above and correct me . Thanks and Regards, Padmini (2 Replies)
Discussion started by: padmisri
2 Replies

8. Shell Programming and Scripting

Setting path

Hi all, I have a java command in a shell script. When i m executing the command from the prompt its working fine. But when i paste the same command in a shell script and execute the shell script it says path not found. Please help. (5 Replies)
Discussion started by: radhika03
5 Replies

9. UNIX for Dummies Questions & Answers

Help on setting path variable

Hi there, I need help on setting the path variable. How can I set the path variable with Bourne Shell. My scripts goes like this, but did not work. #!/bin/sh PATH=/usr/bin:/usr/ucb:/etc:/export/home/zchen/home export PATH Thanks, Z (4 Replies)
Discussion started by: randomcz
4 Replies
Login or Register to Ask a Question