I make some change directory calls inside a.sh, so that the pwd becomes dirname ${0}. The problem I think is that, I'm not invoking a.sh, but sourcing it inside b.sh:
Let's say I invoke b.sh with the following:
/hello/bye/b.sh
Because a.sh makes the following call: dirname ${0}. It gets the path of the current value inside $0, which is actually "/hello/bye/b.sh", since that script is the one being actually invoked.
Hello all,
Here's the scenario:
I've got a script, let's call it script1. This script invokes another script, which we'll call set_env, via the dot "." command, like so:
File:
#!/bin/ksh
#
region_id=DEV
. set_env ${region_id}
and so on. Script set_env sets up an... (2 Replies)
I have a script "abc.sh" in /tmp which has exit 0 as its last line
when I run this script from /tmp/xyz/def.sh script as
. ../abc.sh
then the script executes but the control doesn't return to def.sh script for subsequent commands in def.sh
but if I invoke the abc.sh from inside the... (3 Replies)
Hi there. i'm new user at here
I need help for this. I need to write a script that maintains a database of cryptographic checksums. In other words, I need this script to check the files checksum whether the files has been modified or not. But i got no idea where to start. Hope anyone here can... (8 Replies)
I am developing a script to maintain 'n' number of versions of a file. The script will take a filename as a parameter and the number of versions to maintain. This basically does something like a FIFO. Here is what I developed. But something is not right. I have attached the script. Can u pls help... (2 Replies)
Hi guys,
Good day to all and Happy New Year!!! Cheers!!!
I hope anyone could help/suggest me on hot to create a script that will monitor the directory where files are being dumped. I have a script in CRON that runs everyday and collect for logs with a filename of Output_$(date... (3 Replies)
Hi,
Im trying to run script A which requires path /sbin.
I have a crontab entry to run script A every 10 minutes.
Script A is executed fine by cron, but because script A requires /sbin in its path it fails to run.
My situation is script A get overwritten from time to time so I can't modify... (4 Replies)
My manager required that i keep the hostnames and username and password in a separate file when creating my sftp script.
(Don't mention passwords and sftp...I've talk to him about this several times)
I have a list of hostnames that have to be read in a loop in my main script.
I don't know... (3 Replies)
Hello.
Source file are in : /a/b/c/d/e/f/g/some_file
Destination is : /d/e where sub-directories "f" and "g" may missing or not.
After copying I want /a/b/c/d/e/f/g/file1 in /d/e/f/g/file1
On source /a is top-level directory
On destination /d is top-level directory
I would like... (2 Replies)
#! /bin/ksh
#first.sh
echo "b4 set exit as return"
alias exit=return
echo "call second"
. ./second.sh
echo "after second"
#. ./third.sh
unalias exit
echo "ho lanciato il terzo"
=================//
#second.sh
echo "in scond"
exit
==============//
the above code works in k... (2 Replies)
Discussion started by: mprakasheee
2 Replies
LEARN ABOUT SUNOS
basename
basename(1) User Commands basename(1)NAME
basename, dirname - deliver portions of path names
SYNOPSIS
/usr/bin/basename string [suffix]
/usr/xpg4/bin/basename string [suffix]
dirname string
DESCRIPTION
The basename utility deletes any prefix ending in / and the suffix (if present in string) from string, and prints the result on the stan-
dard output. It is normally used inside substitution marks (``) within shell procedures.
/usr/bin
The suffix is a pattern defined on the expr(1) manual page.
/usr/xpg4/bin
The suffix is a string with no special significance attached to any of the characters it contains.
The dirname utility delivers all but the last level of the path name in string.
EXAMPLES
Example 1: Setting environment variables
The following example, invoked with the argument /home/sms/personal/mail sets the environment variable NAME to the file named mail and the
environment variable MYMAILPATH to the string /home/sms/personal:
example% NAME=`basename $HOME/personal/mail`
example% MYMAILPATH=`dirname $HOME/personal/mail`
Example 2: Compiling a file and moving the output
This shell procedure, invoked with the argument /usr/src/bin/cat.c, compiles the named file and moves the output to cat in the current
directory:
example% cc $1
example% mv a.out `basename $1 .c`
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of basename and dirname: LANG, LC_ALL,
LC_CTYPE, LC_MESSAGES, and NLSPATH.
EXIT STATUS
The following exit values are returned:
0 Successful completion.
>0 An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
/usr/bin
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
/usr/xpg4/bin
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWxcu4 |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
SEE ALSO expr(1), basename(3C), attributes(5), environ(5), standards(5)SunOS 5.10 18 Mar 1997 basename(1)