+ 2

How can I execute a file using ./ if the file is located outside of my pwd??

Suppose there is an application with this path /opt/app/bin/app. Now if I go to this path and execute it using ./app it works fine but when I try to execute it from my home directory by using . /opt/app/bin/app it throws me an error saying "cannot execute binary file" Is this the correct way to traverse?

6th Oct 2020, 1:39 PM
Anurag Mondal
Anurag Mondal - avatar
6 odpowiedzi
+ 5
The leading dot in your command means "relative to the current directory". Remove it and it'll refer to the file in the correct directory
6th Oct 2020, 1:58 PM
Coding Cat
Coding Cat - avatar
+ 1
🇮🇳Vivek🇮🇳 I'm trying to set an alias to execute the application from any directory.
6th Oct 2020, 1:56 PM
Anurag Mondal
Anurag Mondal - avatar
+ 1
I want to traverse to the home directory but without using cd and I want to use the path of the application .i.e /opt/app/bin/app with . or ./
6th Oct 2020, 1:59 PM
Anurag Mondal
Anurag Mondal - avatar
+ 1
Thanks! Thomas
6th Oct 2020, 2:00 PM
Anurag Mondal
Anurag Mondal - avatar
+ 1
You're welcome
6th Oct 2020, 2:01 PM
Coding Cat
Coding Cat - avatar
0
But /opt is always in root directory. Why you are trying from home directory?
6th Oct 2020, 1:47 PM
🇮🇳Vivek🇮🇳
🇮🇳Vivek🇮🇳 - avatar