Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Issues with "source"

Status
Not open for further replies.

skywalkr2

Programmer
Mar 3, 2006
17
US
Hello all,

I am trying to get some of our old code to work, and have been having some troubles this morning. I was wondering if someone could help me.

My environment is HPUX running under ksh. I am having problems with the following statements:

set data [exec which macmenu_source_files]
source $data

If I do this, then I get an error of couldn't read file: no such file or directory. However, if I modify the code to this, then it works (the file macmenu_source_files is executable):

source macmenu_source_files

I need to be able to get the first method to work. Does anyone have any ideas why the first command would work and the second would not?
 
are you sure you didn't use " " instead of ""?

_________________
Bob Rashkin
 
maybe we can see what's going on with eval:
Code:
set data [exec which macmenu_source_files]
regsub ./ $data "" data
set rtn [eval source $data]
puts $rtn

what do you get?


_________________
Bob Rashkin
 
Wow - it locks up... This is the last thing I see:
couldn't read file
 
All I can think of is that the which command is returning some special characters somewhere that are interfering with the source command. Without a UNIX platform to experiment on I don't know if I can go any further. Maybe someone else can chime in (cptk?).

_________________
Bob Rashkin
 
One last thing:
Code:
set data "./macmenu_source_files"
regsub ./ $data "" data
source $data

what happens?


_________________
Bob Rashkin
 
I think you must be right. It must be which. Because the code you gave me here seems to work.
 
That means that which is returning something sinister inside the otherwise inoccuous ./macmenu_source_files

see what string length $data returns. It should be 22.

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top