سؤال

I am new to ns3. i have some simple programs written in c++.

I run my ns3 program by below command

exec "`dirname "$0"`"/../../waf "$@"

Can anyone explain function of above mentioned line?

هل كانت مفيدة؟

المحلول

dirname "$0"

gets the directory name of file containing the command.

"`dirname "$0"`"/../../waf

appends /../../waf to the result obtained by dirname "$0".

So it you obtained /some/arbitray/path from the previous command, this would return /some/arbitray/path/../../waf

exec "`dirname "$0"`"/../../waf "$@"

replaces the shell with the command obtained above and passes the arguments that were passed to the script containing the original command.


As an example, if your command was in a file contained in a directory /d1/d2/d3/d4/d5 and you executed it by saying:

sh myfile foo bar "foo bar"

then the command being executed would be:

/d1/d2/d3/d4/d5/../../waf foo bar "foo bar"
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top