如何从当前进程/可执行文件运行的位置查找路径? [英] How to find path from where current process/executable is running?

查看:158
本文介绍了如何从当前进程/可执行文件运行的位置查找路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我连接到本地unix服务器盒时,我正在运行一些可执行文件.

I am running some executables while connected to a local unix server box.

说,我正在尝试运行可执行文件"abc".现在服务器可能已经为"abc"提供了别名.我如何知道该路径?像这样,如果我调用'abc',它实际上可能是从/opt/corp/xyz/abc中运行的.如何得知我从哪个路径调用可执行文件?

Say, I'm trying to run an executable 'abc'. Now the server might have provided an alias for 'abc'.. How do I get to know of this path? As in, if I invoke 'abc', it might actually run it from, say, /opt/corp/xyz/abc .. How do I get to know from what path I'm invoking the executable?

通过我在HP-UX上运行的方式:D

By the way I'm running on HP-UX :D

推荐答案

"which abc"以显示您要呼叫的abc

"which abc" to show which abc you would be calling

或"alias"以列出别名

也许是从脚本内部回显$ 0",或者以其他方式检索argv [0].

perhaps "echo $0" from inside a script, or retrieving argv[0] some other way.

这篇关于如何从当前进程/可执行文件运行的位置查找路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆