Solved

symlinks

Posted on 2000-03-06
23
485 Views
Last Modified: 2013-12-27
I have an application which is actually a windows application but the files for the application are sitting on a solaris server.

The application has a config directory which it expects to find off the application directory. I would like to have this config directory actually in the home directory of each user so that each is able to have their own config directory.

I am thinking something along the lines of a symlink that points to ~/config although exactly how to do this escapes me at the moment... ie.

ln -s \~/config config
doesn't work because then the '~/' is interpreted as part of the file name.

ln -s ~/config config
doesn't work because it replaces the ~ with my home dir path...

Can anyone tell me how I'd do this ?
0
Comment
Question by:jaredc071598
  • 7
  • 5
  • 3
  • +4
23 Comments
 
LVL 3

Expert Comment

by:freesource
ID: 2590320
Let's say the configuration file is in /etc/config.

ln -s /etc/config ~/config

Just make sure you get the permissions right so that everyone can use the file, and realize if normal users can access the central configuration file in this manner, they also can change the central configuration file if they have write permissions.
0
 
LVL 2

Expert Comment

by:GP1628
ID: 2593165
Im not sure that you can do what you want to do.

If you link to the config directory then everyone has only one config file. The main one.

For the program to accept multiple config files that will have to be an option of the program.  Something along the line of a command-line option when the program is called such as

theprogram.exe -c ~/config

then just give each user their own script to call the program.

OR if the program can accept alternate directorys for config but doesnt recognize ~ give each user a script for

theprogram.exe -c ./config

where the period will specify the directory that the script is run from.

0
 

Author Comment

by:jaredc071598
ID: 2593851
Ok, GP1628

Unfortunately the program doesn't have a command line option for the config directory - that would be nice and easy.

And I think freesource missed the idea a little. So I will try to clarify a little more.

The program requires a directory structure as follows.

program_dir/
     config

I would like to set it up such that config is a symlink to a config directory inside each and every users home.

ie

program_dir/
     config -> ~/config

so that if I run the program it picks up the config files from my home directory, and if the person sitting on my right runs the program it picks up the config files from his home directory. In this way there is no central config file - this is so that each user is able to have their own macros and setup and so forth without interfering what other people want to have set up.



0
 
LVL 2

Expert Comment

by:GP1628
ID: 2593979
Thats just it. links wont do that.

Unless the program itself is willing, I cant think of a way to do it.

Is the config path absolute? or is it relative? Does it look for the configs in a particular directory or one particular to the location that the program starts up in?

If there is no command line option.... is ther ean ini file which might inclucde the path structure that it is to use for its files? If installation wrote a line that the config resides in /myprog/config then removing the /myprog/ will often cause it to look in the directory its called in for the files.

Gandalf Parker
0
 
LVL 2

Expert Comment

by:GP1628
ID: 2593998
Hmmmm I thought about it some more. The problem with links is that its a command that allows many people to have access to one file, you kindof want it to work in reverse with one file being access to many peoples files.
This is purely a shot in the dark but I believe since its unix it should work.

If each person had a script which
 ln -s config /theprogram/conf
 theprogram

then it would create a new link each time they run it. Im not sure if it would overwrite the old link of the other user but if it did then this should work.
Since the program has already read the config and is already up and running it shouldnt be affected by the fact that the link changed.

You would have to test it to be sure.

Gandalf Parker
0
 
LVL 3

Expert Comment

by:freesource
ID: 2594000
Exactly which program is this anyways?
0
 

Author Comment

by:jaredc071598
ID: 2594290
I may have to try that Gandalf - although I don't expect it will work so nicely because the config files get written to by the program as well, I presume that it would require the link to be intact when it comes to do the write, otherwise I may be trying to overwrite someone elses config files.

With regards to what the program is it's a windows text editor by the name of MultiEdit.
0
 

Author Comment

by:jaredc071598
ID: 2594297
Is there then an alternative to a link which may work in this way that I am unaware of ? (My unix knowledge isn't particularly large).
0
 
LVL 3

Expert Comment

by:freesource
ID: 2594698
Yes, the way to do this would be to write a wrapper script.

Instead of running MultiEdit you would run the wrapper instead which would take care of finding the configuration file for whatever user runs the program.  There lot's of ways it could be written to do this.

Once way would be to simply copy over the configuration file to the only directory MultiEdit looks in, then execute MultiEdit, when MultiEdit finishes it will just remove the program.

Like this:

#!/usr/bin/perl

# By freesource
# Give it a name .. chmod 755 name.
# Put it in a Path
# Edit this to specifications, make sure
# the first bang line points to perl on
# your system . make sure you have perl
# or write something similiar in shell
# script.

$user_conf = $ENV{"HOME"} . "/config";

# copy user configuration file over
system "copy $user_conf /MultiEdit";

# run program
system "MultiEdit";

#clean out program directory
system "rm /MultiEdit/config";

   


0
 
LVL 3

Expert Comment

by:freesource
ID: 2594722
Oh, and this line:

# copy user configuration file over
system "copy $user_conf /MultiEdit";

Should be this way instead

system "cp $user_conf /MultiEdit";

:)

.... so

#!/usr/bin/perl

# By freesource 1-8-2000
# Give it a name .. chmod 755 name.
# Put it in a Path
# Edit this to specifications, make sure
# the first bang line points to perl on
# your system . make sure you have perl
# or write something similiar in shell
# script.

$user_conf = $ENV{"HOME"} . "/config";

# copy user configuration file over
system "cp $user_conf /MultiEdit";

# run program
system "MultiEdit";

#clean out program directory
system "rm /MultiEdit/config";

0
 

Author Comment

by:jaredc071598
ID: 2598196
Hmmm, there is a small problem with this.

Firstly the program is a Windows program so it actually gets run on the Windows boxes and the files are kept on the UNIX box.

The second problem is that the link to the config files is live and the files may change during a session - if a second user were to open up a session it may mess up the first user - or not let the second user overwrite the config files which may still be held open by the program.

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 3

Expert Comment

by:freesource
ID: 2598685
You could use wine to run the program on the unix boxes, and a lock could be used.  It sounds like there will be many users using the program concurrently, but there are tricks to accomplish this.  Where can I find this program to try some experiments?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 2599720
as GP1628 said, the only way might be a wrapper script which generates the symlink on the fly, but then you run into problems when more than on user accesses the program.

> Hmmm, there is a small problem with this.
> Firstly the program is a Windows program ..
NO, this is the only problem ;-)
Windows programs are designed for single-user, single-tasking, usually, so there is no need for multi-user support, IT'S WINDOZE. Dot.

If this stupid Windoze program cannot deal with multiple users, you may try to make a new installation for each user, therefore using it's own config directory for each user.

0
 

Author Comment

by:jaredc071598
ID: 2602895
freesource - MultiEdit is made by a company call american cybernetics - I can't see a web address on it.

ahoffmann - yes I tend to agree with you that windows is the problem - but that is the environment I am working under (and personally I don't actually know enough about unix nor have the time to move myself to it now.

If no-one comes up with an answer that is easier for me I think I'll have to  give this one to Gandalf
0
 
LVL 5

Expert Comment

by:paulqna
ID: 2606302
when you say:

ln -s ~/config config
doesn't work because it replaces the ~ with my home dir path...

its worth trying to do
# su <username>
then
# ln -s ~/config config # orwathever you want
and then to get back to your user
# exit

Hopeing I understood your question...

0
 

Author Comment

by:jaredc071598
ID: 2618071
paulqna,

when you do a ln -s ~/config config the command interpreter will interpret the ~ immediately as being the home directory of the current user, hence if I do that the link is to /usr/jaredc/config, when the next person comes along the link will still point into my home dir rather than theirs.

It is possible to escape the ~ character but then it is not interpreted when you use the link either.
0
 
LVL 1

Expert Comment

by:markus_baertschi
ID: 2623145
What about putting the other way round. Instead of creating link
for the config file you create a links for all the files of the program.

You have a directory /home/program holding all the program files.
You have a directory /home/user1/program wit the config file
and links for all other files pointing to /home/program.
Depending on how your PC is getting at the files (NFS, samba)
you can not use symlinks, but neet to use 'normal' links. As
long as your fileas are in the same filesystem on the unix box
it will work the same.

Markus
0
 
LVL 5

Expert Comment

by:paulqna
ID: 2625192
Then

# ln -s ~/config config # orwathever you want.

Should be

# ln -s \~/config config # orwathever you want.

Paul
0
 
LVL 5

Expert Comment

by:paulqna
ID: 2625194
Sorry when i was reading your question i saw this was a really stupid one... ;(
0
 

Author Comment

by:jaredc071598
ID: 2626563
Markus - This one is a good idea, and I am trying that as well, although unfortunately I think it may create other problems as well.

But certainly this is the closest anyone's come to an idea that may solve the problem so far.
0
 
LVL 1

Accepted Solution

by:
markus_baertschi earned 50 total points
ID: 2627086
Just some more remarks.
Most PC apps unfortunately beleave to be only thing the (one) user of the (single) machine ever wants to run...

However, for my thing to work there are two ways:
1) You export /home on your server and will see the files as X:\user1\program on the PC.
In this case symlinks will work, but users can see all other users
directories on drive X:. This might be a problem.
2) You export /home/user1 on your server and will see the files as X:\program on the PC.
Here you need 'normal' links. For this to work the programs files
and the users files need to be in the same filesystem.

How big is this app anyway ? Is is huge enough to bother ? It might
be easier and cheaper (work !) just to spend some MB/GB and install
is in each users directory.

Not nice, but simple and reliable !
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 2627318
still suggested to install it per user.
I'm also not shure if it is possible to use symlinks for the program files (instead of a new installation), 'cause of M$'s proprietary file-locking when using a program or a data file used by this program.
This needs to be tested extensively.
0
 
LVL 2

Expert Comment

by:festive
ID: 2643421
something that may help:

after you have created the directoy and set group permissions on it carefully, you could put a symbolic link in /etc/skel which should then allow automatic replication of the directory tree (and symbolic link) for each new user.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now