04-26-2010
If you're running bash, you may be on linux, and may thus have the general purpose command 'realpath'.
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello expert,
What I want is to determine whether the script is called from CRON or it is executed interactively?
I tried the following but no luck:
#!/bin/ksh
cronID=`pgrep -x cron`
GPID=`ps -ef -o ppid,pid | grep " $PPID$" | awk '{print $1}'`
if ; then
echo I am being run... (15 Replies)
Discussion started by: wes_brooks
15 Replies
2. UNIX for Advanced & Expert Users
Hi,
when I execute some simple commands on my solaris system, I am getting the following warning message:
Could anybody tell me what could be the reason
Ex:- If I give the command,
which ls
Warning: cannot determine current directory
... (15 Replies)
Discussion started by: axes
15 Replies
3. Shell Programming and Scripting
Hi All,
I've searched through the forum for a solution to this problem, but I haven't found anything. I have 2 script files that are in different directories.
My first script, let's call it "/one/two/a.sh" looks like this:
#!/bin/sh
IN_DIR=`dirname $0`
CUR_DIR=`pwd`
cd $IN_DIR... (4 Replies)
Discussion started by: mrbluegreen
4 Replies
4. Shell Programming and Scripting
Hi,
Is there a way to determine if the script has been invoked manually or not( might be invoked by a schedular or crontab)?
Thanks, (8 Replies)
Discussion started by: hitmansilentass
8 Replies
5. UNIX for Dummies Questions & Answers
My n00b question:
I am trying to write a script that I can place on a flash drive and then move from computer to computer and install a file, which is bundled with the script. (ie the script is at /Volumes/FlashDrive/Folder/Script, the file is at /Volumes/FlashDrive/Folder/File)
So far I have... (1 Reply)
Discussion started by: madmacs
1 Replies
6. HP-UX
how could I use shell script to determine which CPU structure
because I found that I compile my program under Itanium base that cannot run on the PA-RISC base
but PA-RISC program can run on Itanium base
i would like to use shell script to know which CPU structure it is,how could i do
thanks (1 Reply)
Discussion started by: alert0919
1 Replies
7. UNIX for Dummies Questions & Answers
Hi all
So I am thinking my inability to cope with math is bogging me down here so Im asking for help.
I want to determine how long a user has been logged on for by using the date and who commands to determine the time they have been logge don.
My problem is that I keep getting the wrong... (2 Replies)
Discussion started by: losingit
2 Replies
8. Web Development
how do we determine if ip addresses are hosting IIS version 7.x or Apache 2.2.x. ? (3 Replies)
Discussion started by: NameSake
3 Replies
9. Shell Programming and Scripting
Need help with the script, I am trying to include this script as part of kickstart profile.
based of the host's IP address, in this case if the host is IP starting with 10.10.3.* or 10.10.6.*, I will be pushing appropriate routing file from my web server.
I validate host IP from nslookup.
... (3 Replies)
Discussion started by: bobby320
3 Replies
LEARN ABOUT DEBIAN
realpath
REALPATH(1) Debian REALPATH(1)
NAME
realpath - return the canonicalised absolute pathname
SYNOPSIS
realpath [-s|--strip] [-z|--zero] filename ...
realpath --h|--help
realpath --v|--version
DESCRIPTION
realpath converts each filename argument to an absolute pathname, which has no components that are symbolic links or the special . or ..
directory entries. (See realpath(3) for more information.)
Each path component in the filename must exist, otherwise realpath will fail and non-zero exit status will be returned.
Please note that mostly the same functionality is provided by the `-e' option of the readlink(1) command.
When the -s option is used realpath only removes the . and .. directories, but not symbolic links from filename. If the given filename
argument is relative (i.e. does not start with `/'), realpath -s prepends to it the current directory name as obtained from the getcwd(2)
system call before further processing.
Each converted pathname is output to the standard output, on its own line.
OPTIONS
-s, --strip
Only strip . and .., components, but do not resolve symbolic links.
-z, --zero
Separate output filenames with the null character instead of newline, so it can be used with the `-0' option of xargs(1).
-h, --help
Print short usage information.
-v, --version
Show realpath's version number.
EXAMPLES
For the examples below let's suppose that /usr/bin/X11 is a symbolic link, pointing to directory /usr/bin.
Example 1
Regardless of what the current directory is
realpath /../usr/bin/X11/./xterm
prints
/usr/bin/xterm
but
realpath -s /../usr/bin/X11/./xterm
outputs
/usr/bin/X11/xterm
Example 2
When the current directory is /usr/bin/X11 (which is still a symbolic link to /usr/bin), the output of both
realpath ./xterm
and
realpath -s ./xterm
will be
/usr/bin/xterm
Example 3
Providing that the current directory is /home/user (and the directory exists before and during the realpath run), the command
realpath ../path/to/some/./non-existent/./directory/../or/../file
will fail with the following error
../path/to/some/./non-existent/./directory/../or/../file: No such file or directory
but
realpath -s ../path/to/some/./non-existent/./directory/../or/../file
will return
/home/path/to/some/non-existent/file
EXIT STATUS
realpath returns a zero exit code when all pathnames were successfully converted.
In case of any errors (e.g. missing or unavailable directories in the path), realpath prints error message to stderr and returns a non-zero
exit code.
SEE ALSO
basename(1), dirname(1), readlink(1), chase(1), realpath(3)
BUGS
Hopefully none :)
If you find some, please report them via the normal Debian bug reporting system, see the file /usr/share/doc/debian/bug-reporting.txt in
the package doc-debian or the reportbug(1) man page.
AUTHOR
Originally written by Lars Wirzenius <liw@iki.fi>, as a part of the dwww package. Robert Luberda <robert@debian.org> currently maintains
and extends it.
realpath is licensed via the GNU General Public License. While it has been written for Debian, porting it to other systems is strongly
encouraged.
Debian October 16th, 2011 REALPATH(1)