Forum > Unix
How to get launched app name in case of symlink
TRon:
--- Quote from: PascalDragon on January 18, 2024, 09:59:41 pm ---On *nix you can directly use argv[0] for that (cause ParamStr(0) returns /proc/self/exe).
--- End quote ---
Ah, then I am mistaken. I stand corrected. Thank you !
zim:
Sorry, all that stuff does not help. Either ParamStr(0) or argv[0] contains symlink target name, not source.
The problem is I want to share same executable between several tasks located in different folders and care on exact action depending on the folder.
But in the said case, even I run executable (symlinked to every specified folder) - every time I get the same app name, not different names
TRon:
--- Quote from: zim on January 23, 2024, 03:43:22 pm ---Sorry, all that stuff does not help. Either ParamStr(0) or argv[0] contains symlink target name, not source.
--- End quote ---
Oh, that is strange as ti works for me.
Which Linux and version of Free Pascal are you using ?
--- Code: ---./startupper
Example to demonstrate differences between executable invoked
from command line a) directly and b) using a symbolic link
Running this executable file directly (/media/ramdisk/start/startupper)
argv[0] = /media/ramdisk/start/startupper -- /media/ramdisk/start/startupper
paramstr(0) = /media/ramdisk/start/startupper
/proc/self/cmdline = /media/ramdisk/start/startupper INFORM
ExpandFileName(argv[0]) = /media/ramdisk/start/startupper
---
Running this executable file indirectly using a symbolic link (some_directory/test_symlink)
argv[0] = some_directory/test_symlink -- /media/ramdisk/start/some_directory/test_symlink
paramstr(0) = /media/ramdisk/start/startupper
/proc/self/cmdline = some_directory/test_symlink INFORM
ExpandFileName(argv[0]) = /media/ramdisk/start/some_directory/test_symlink
---
TODO: clean-up the mess and fix expandfilename usage
--- End code ---
Navigation
[0] Message Index
[*] Previous page