Refering to Jim's previous comments and some posts by Perderabo (here and here) it's a really hard task. For example, try running your script as
or:
Actually I think these examples do not really count, since this is piping the contents of a script to a shell. Therefore the executing program/script being called is the shell itself. In other words, the part of the pipe that the executing shell is aware of does not "know" the origins of the stream of characters that it receives as its input.
This is an artificial way of calling the script and this is not what you would write the code for in my opinion.
Quote:
Originally Posted by chebarbudo
Not quite true:
I think th reason this does not work is because you appear to have "." in your search path, which should not be the case, since it is a security risk. The "." should be removed from your PATH variable, which would force you to use bash ./s instead. Then the "which $0" construction should be valid I think.
Actually I think these examples do not really count, since this is piping the contents of a script to a shell. Therefore the executing program/script being called is the shell itself. In other words, the part of the pipe that the executing shell is aware of does not "know" the origins of the stream of characters that it receives as its input.
This is an artificial way of calling the script and this is not what you would write the code for in my opinion.
I agree
Quote:
Originally Posted by Scrutinizer
I think th reason this does not work is because you appear to have "." in your search path, which should not be the case, since it is a security risk. The "." should be removed from your PATH variable, which would force you to use bash ./s instead. Then the "which $0" construction should be valid I think.
Nope. I have no such "." in my PATH. Try it yourself and you'll see.
Currently I am using this laborious command
lvdisplay | awk '/LV Path/ {p=$3} /LV Name/ {n=$3} /VG Name/ {v=$3} /Block device/ {d=$3; sub(".*:", "/dev/dm-", d); printf "%s\t%s\t%s\n", p, "/dev/mapper/"v"-"n, d}'
Would like to know if there is any shorter method to get this mapping of... (2 Replies)
I can not run iwmodelc from command line. It says file not found.
Please look at the command line output below-ksh: /app/Autonomy/Interwoven/TeamSite/bin: cannot execute $ pwd /app/Autonomy/Interwoven/TeamSite/bin $ ls email_to.ipl iwfilestate iwrecentusers iwabort ... (2 Replies)
I am not sure here is the right place to post this question.
as openvms is under HP's belt now, i guess here might be the right place to try my luck.
we have very old machines here which are still running quite well. (APLHASTATION 200 WITH OPENVMS 6.1)
the only problem is difficulty of... (2 Replies)
I have a script in which i want to print absolute path of the same script irrespective of path from where i run script.
I am using
test.sh:
echo "pwd : `pwd`"
echo "script name: $0"
echo "dirname: `dirname $0`"
when i run script from /my/test/dir/struct as ../test.sh the output i... (10 Replies)
How does the program know the full path of itself when the program is running in certain diretory? BTW, I have no "argv" information of main() functino.
(The program is written in C++ on linux platform) (1 Reply)
Hi,
I just want to know any code by which i can get the path of the script which i am running. This is required to store the output in the same directory from where the script is running. pwd fails if I give absolute path of script from some other directory.
Thanks in advance
Puneet (3 Replies)
Hi,
i have a script which need to do behave differently when run as a startup process from init.d/ rc2.d script and when run manually from shell.
How do i distinguish whether my script is run by init process or by shell??
Will the command
/proc/$$/psinfo | grep "myscript" work well???... (2 Replies)
ok,
i am aware of adding the directory where the files are located into the .profile file but the problem is, its not working for me.
can someone please spell out how to properly edit these configuration files so i can run a command anywhere on the system without having to be in the... (2 Replies)
Hi-
I need the cpp call that will tell me the full path to the app I'm running in. For example, I'm running in a loaded library for either mozilla or firefox, but would like to know the full path to the executable
/usr/bin/firefox
/usr/bin/mozilla
/usr/local/firefox1_5
etc...
(For... (4 Replies)