07-16-2007
Quote:
Originally Posted by
krishmaths
Many scripts are executed in the following way.
. /scriptname
Even when the file does not have execute permission, it can be executed this way. How does this work?
In this case, scriptname is passed as an argument to the current shell i.e. you are asking the current shell to execute it.
When you do ./scriptname, you are executing scriptname in a subshell within the current shell.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
what does this symbol ~ represent in unix for example....
If i create directories called personal and lab and lab5 and the command chmod 776~/lab5 is issued. What results would i expect to get. basically i know that chmod 776 would prevent others from executing the files in the directory but... (2 Replies)
Discussion started by: BigTool4u2
2 Replies
2. Shell Programming and Scripting
Hi ,
i have few doubts about the braces and spaces which are quite often used:
for instance:
when i try the belo command it will not work
export variable= cat filename
rather when i try the cat command without any space it works fine
export variable=cat filename
and... (3 Replies)
Discussion started by: ahmedwaseem2000
3 Replies
3. UNIX for Dummies Questions & Answers
Hi,
I am a newbie in unix shell scripting and I am trying to understand the result of the following line :
ls -l $1*$4*ready
I understand the ls-l but the rest is just really confusing. Any help would be appreciated.
TIA (3 Replies)
Discussion started by: nickcarter
3 Replies
4. Solaris
this post is related to the arrangements of libraries in a solaris-8 distribution.
i want to build external packages on solaris-8
i need to know why libraries are scattered in a solaris distribution among different below mentioned directories,
please tell me whats the importance ??
/lib... (3 Replies)
Discussion started by: mobydick
3 Replies
5. AIX
Hello... I am getting ready to create a bunch of groups for several of our servers all of which are running Aix 5.3. We really want to keep people away from using the root login and as such the systems have been hardened using aixpert and if it is absolutely needed people must su -.
There are... (1 Reply)
Discussion started by: dgaixsysadm
1 Replies
6. Shell Programming and Scripting
What is the Significance of '{}' \; in UNIX? (2 Replies)
Discussion started by: Shell_Learner
2 Replies
7. Shell Programming and Scripting
What is the significance of the forward slash(/) while specifying a directory?
cp -av /dir/ /opt/
and
cp -av /dir /opt
Does effectively the same job it seems? (2 Replies)
Discussion started by: proactiveaditya
2 Replies
8. Solaris
What is the significance of pfiles?
What is the use of it and how and where to use it?:wall: (2 Replies)
Discussion started by: varunksharma87
2 Replies
9. Shell Programming and Scripting
Hi
I was trying to understand what ':-' means when used with variables
echo ${x:-10}
if
Thanks (4 Replies)
Discussion started by: zulfi123786
4 Replies
10. UNIX for Dummies Questions & Answers
I'm taking a LINUX and UNIX class and we are using bash as the shell in terminal. On my mac-book I use zsh only because my professor had a pretty cool start-up file for it.
It has benefited me in becoming familiar with different shells. However, I'm having a hard time understanding the purpose... (4 Replies)
Discussion started by: syregnar86
4 Replies
exec(1) User Commands exec(1)
NAME
exec, eval, source - shell built-in functions to execute other commands
SYNOPSIS
sh
exec [argument...]
eval [argument...]
csh
exec command
eval argument...
source [-h] name
ksh
*exec [arg...]
*eval [arg...]
DESCRIPTION
sh
The exec command specified by the arguments is executed in place of this shell without creating a new process. Input/output arguments may
appear and, if no other arguments are given, cause the shell input/output to be modified.
The arguments to the eval built-in are read as input to the shell and the resulting command(s) executed.
csh
exec executes command in place of the current shell, which terminates.
eval reads its arguments as input to the shell and executes the resulting command(s). This is usually used to execute commands generated as
the result of command or variable substitution.
source reads commands from name. source commands may be nested, but if they are nested too deeply the shell may run out of file descrip-
tors. An error in a sourced file at any level terminates all nested source commands.
-h Place commands from the file name on the history list without executing them.
ksh
With the exec built-in, if arg is given, the command specified by the arguments is executed in place of this shell without creating a new
process. Input/output arguments may appear and affect the current process. If no arguments are given the effect of this command is to mod-
ify file descriptors as prescribed by the input/output redirection list. In this case, any file descriptor numbers greater than 2 that are
opened with this mechanism are closed when invoking another program.
The arguments to eval are read as input to the shell and the resulting command(s) executed.
On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways:
1. Variable assignment lists preceding the command remain in effect when the command completes.
2. I/O redirections are processed after variable assignments.
3. Errors cause a script that contains them to abort.
4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari-
able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not
performed.
EXIT STATUS
For ksh:
If command is not found, the exit status is 127. If command is found, but is not an executable utility, the exit status is 126. If a redi-
rection error occurs, the shell exits with a value in the range 1-125. Otherwise, exec returns a zero exit status.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
SEE ALSO
csh(1), ksh(1), sh(1), attributes(5)
SunOS 5.10 17 Jul 2002 exec(1)