I have a bash script foocaller, which calls a ruby script foo:
foocaller
/path/to/foo
Within foo, I want to get the path of foocaller. Following this suggestion, I put the following code to do that:
foo
#!/usr/bin/env ruby
puts File.read("/proc/#{Process.ppid}/cmdline")
When I run:
$ bash foocaller
then I get the desired:
bash^@/path/to/foocaller
but when I directly call foocaller:
$ foocaller
then I get this:
/bin/bash^@--noediting^@-i
which does not show the path to foocaller. How can I get the path to foocaller by directly calling foocaller without bash?
exitat the end your foocaller script, otherwise, foocaller may execute foo in the same process. – Stéphane Chazelas Jun 15 '14 at 19:01