Hi together,
I want to call a PB program with different names (symbolic links).
Now I have the problem to figure out the name of the caller.
ProgramFileName() returns always the name of the 'real' program.
Any ideas?
Bernd
Symbolic links and ProgramFileName()
Try this:
Code: Select all
MessageRequester(ProgramFilename(), GetEnvironmentVariable("_"))
Hi Marlin,
yes it works and ... no it works not.
Since you ask the shell variable $_ it gives you only information about the last called program from out of the shell..
So, if you call your linked PureBASIC file from inside of a script, you get the name of the script, and not the name of the link of the PureBASIC file.
For me, unfortunately, your trick will not work.
But many thanks, it was a good try.
Bernd
yes it works and ... no it works not.

Since you ask the shell variable $_ it gives you only information about the last called program from out of the shell..
So, if you call your linked PureBASIC file from inside of a script, you get the name of the script, and not the name of the link of the PureBASIC file.
For me, unfortunately, your trick will not work.
But many thanks, it was a good try.
Bernd
I found a solution, but it is one which I not really like:
When I use 'hard' links it works with ProgramFilename().
But since I want to use the program on one side as a cgi and on the other side as a standalone program, I can not be shure that the web stuff is not on an other partition or harddisk.
So the hard link will not work.
Bernd
When I use 'hard' links it works with ProgramFilename().
But since I want to use the program on one side as a cgi and on the other side as a standalone program, I can not be shure that the web stuff is not on an other partition or harddisk.
So the hard link will not work.
Bernd
I just tried to reproduce that, but I could not:infratec wrote:if you call your linked PureBASIC file from inside of a script, you get the name of the script, and not the name of the link of the PureBASIC file
I compiled the above code as "callme.bin".
(puttig all on the Desktop - don't think it should behave differently somewhere else)
Code: Select all
$ ln -s callme.bin call2
Code: Select all
#!/bin/bash
./call2
./callme.bin
Code: Select all
$ ./runcall.sh
Code: Select all
./call2
Code: Select all
./callme.bin
However, when clicking on the link "call2" on the desktop I get the full path to the final executable.
Yes, ProgramFilename() will return the name of the called hardlink.
You could then create hard links where your executable is located
and create soft links on other filesystems to those hard links.
But beware: if you create your original executable again (with the PB compiler),
the formerly created hard links will still point to the old version of your executable!
Can you give a setup that can be used to reproduce the problem you mentioned

Hi Marlin,
my results are different.
Here my code:
The orignal file is called "NameTest".
Than I created a link "NT2"
Than I created the following "NT3" script:
As result I got 2 times NT3 and not NameTest and NT2.
I use Kubuntu 9.04, but I think the system doesn't matter in this case.
One Moment
That's strange:
I noticed that you use "#!/bin/bash". I used "#!/bin/sh".
When I use "#!/bin/bash" it works

Ok, my /bin/sh is a link to /bin/dash and not to /bin/bash.
Hm, but that's even not nice, so it depends also on the used shell.
So I still think that we need a global PureBASIC solution for this.
Bernd
my results are different.
Here my code:
The orignal file is called "NameTest".
Than I created a link "NT2"
Than I created the following "NT3" script:
Code: Select all
#!/bin/sh
./NameTest
./NT2
I use Kubuntu 9.04, but I think the system doesn't matter in this case.
One Moment

That's strange:
I noticed that you use "#!/bin/bash". I used "#!/bin/sh".
When I use "#!/bin/bash" it works


Ok, my /bin/sh is a link to /bin/dash and not to /bin/bash.
Hm, but that's even not nice, so it depends also on the used shell.
So I still think that we need a global PureBASIC solution for this.
Bernd