Cookie Consent by Free Privacy Policy Generator 📌 While running a bash script using a hard symbolic link, how can it get the absolute path of its executing script?

🏠 Team IT Security News

TSecurity.de ist eine Online-Plattform, die sich auf die Bereitstellung von Informationen,alle 15 Minuten neuste Nachrichten, Bildungsressourcen und Dienstleistungen rund um das Thema IT-Sicherheit spezialisiert hat.
Ob es sich um aktuelle Nachrichten, Fachartikel, Blogbeiträge, Webinare, Tutorials, oder Tipps & Tricks handelt, TSecurity.de bietet seinen Nutzern einen umfassenden Überblick über die wichtigsten Aspekte der IT-Sicherheit in einer sich ständig verändernden digitalen Welt.

16.12.2023 - TIP: Wer den Cookie Consent Banner akzeptiert, kann z.B. von Englisch nach Deutsch übersetzen, erst Englisch auswählen dann wieder Deutsch!

Google Android Playstore Download Button für Team IT Security



📚 While running a bash script using a hard symbolic link, how can it get the absolute path of its executing script?


💡 Newskategorie: Linux Tipps
🔗 Quelle: reddit.com

I created a compose.sh script in the /var/www/vhosts/compose2 directory, in which composer's composer.phar is installed. Then in my /var/www/vhosts/symfony5/project directory I created a hard symbolic link to this composer.sh script file in the /var/www/vhosts/compose2 directory. In the script file I want to get the absolute path of the script's symbolic link so I can execute composer.phar without hardcoding its absolute path into the script.

I found that $0 has ./compose.sh, which doesn't help. And the ls -la command doesn't seem to have any options that expand the compose.sh link to /var/www/vhosts/compose2/composer.sh when the ls -la command is run from my symfony5/project directory where it only sees the symbolically linked composer.sh script file. I found -H, -L, and a few --... related options, but these all show .composer.sh when the ls command is run is run from the symfony5/project directory.

Just a couple of things related to bash the compose.sh script:

I used to run the compose.phar command dirctly using a relative path, ../../compose2/composer.phar, but this complicated things a bit because most documentation assumes you've got the composer's 'home' directory in PATH, which I don't, nor want. So I have to remember to use either the relative path or absolute path to the compose2 directory, and that when the docs 'say' composer, I need to use composer.phar.

However, with my new composer.sh symbolically linked file and the composer.sh script, I can run composer from the project directory. To make all of this look even more like what's in the docs, I can take this a step closer by using an alias to change composer without the path or the sh extension to composer.sh and then execute my symbolically linked script. Yes, I realise that this last part could be done by just naming the symbolic link as compose, but I like seeing the sh extension on the file name to remind me that the link is to a script file. As to the alias, when or if I use that, I would use it to substitute the word composer typed in my commandline to composer.sh without any path, that way my use of a script to run composer is almost invisible, and the only part of all this that needs to 'know' the actual path of the composer.sh file in the compose2 directory, and so composer.phar PHP script, is the symbolic link in each project directory where composet is used.

Thanks.

submitted by /u/SymfonyWonderer
[link] [comments] ...



📌 While running a bash script using a hard symbolic link, how can it get the absolute path of its executing script?


📈 138.72 Punkte

📌 Back to bash: Inception, running bash inside bash


📈 41.38 Punkte

📌 Made a bash script for easily executing the Docker image security scanner Clair


📈 37.25 Punkte

📌 permission denied error while executing perl script from jump server to Remote Linux server.


📈 36.7 Punkte

📌 Fix “Permission Denied” Error while Running Bash Script on Linux


📈 35.96 Punkte

📌 Fix “Permission Denied” Error while Running Bash Script on Linux


📈 35.96 Punkte

📌 Bash Script Include Another Bash Script


📈 33.49 Punkte

📌 niieani/bash-oo-framework: Bash Infinity is a modern boilerplate / framework / standard library for bash


📈 32.4 Punkte

📌 Bash Scripting - BASH Scripts For Heavy Commandline Users [Bash Snippets]


📈 32.4 Punkte

📌 Bash Scripting - BASH Scripts For Heavy Commandline Users [Bash Snippets]


📈 32.4 Punkte

📌 CVE-2023-51127 | FLIR AX8 up to 1.46.16 Symbolic Link File path traversal


📈 31.96 Punkte

📌 Docker Trick: Running Containers Efficiently Using A Bash Script


📈 30.82 Punkte

📌 Error while executing "make install" for libgraph


📈 30.75 Punkte

📌 Can you get a virus / malware without executing a file?


📈 30.46 Punkte

📌 CVE-2022-20962 | Cisco Identity Services Engine absolute path traversal (cisco-sa-ise-path-trav-f6M7cs6r)


📈 28.56 Punkte

📌 Absolute Path vs Relative Path in Linux


📈 28.56 Punkte

📌 DevOps Interview:Absolute path and Relative path in Linux


📈 28.56 Punkte

📌 One bash command to search file in system with fzf/dmenu/rofi and get share link on fly using CURL.


📈 28.23 Punkte

📌 Bash add pause prompt in a shell script ( bash pause command )


📈 27.54 Punkte

📌 What is a Bash Script? [13 of 20] | Bash for Beginners


📈 27.54 Punkte

📌 What to look for after successfully executing a Directory (PATH) Traversal attack?


📈 27.42 Punkte

📌 How can a bash script ssh command fail by just changing the script name?


📈 27.22 Punkte

📌 How to Get Help in Bash [4 of 20] | Bash for Beginners


📈 27.02 Punkte

📌 Problem in executing inline perl script through remote shell


📈 26.45 Punkte

📌 Shell PHP Logger - Reveal true server ip executing a php script


📈 26.45 Punkte

📌 What's the absolute worst that can happen from clicking a link?? (help!!!)


📈 26.19 Punkte

📌 Bash/KSH: Define Delimiter (IFS) While Using read Command


📈 26.14 Punkte

📌 I automate sending birthday and festival wishes to my friends by running a bash script in cronjob.


📈 25.72 Punkte

📌 Microsoft Warns of Email Attacks Executing Code Using an Old Bug


📈 25.61 Punkte











matomo