11-22-2011
forking question myscript vs . myscript vs exec myscript
I have a question about the following
what is the difference between running myscript vs . myscript vs exec myscript ?
I know that when you just run myscript it will fork a child process and run the script and exits.
What does the . myscript and exec myscript do and why is it different and needed ?
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
When I compile this C programme I get different outputs each time I run it
Please explain to me whats happening in the code if you can give me a detailed explanation with the schedular functionality it will help a lot. Because I am stuck with this.
#include <stdio.h>
main(){... (3 Replies)
Discussion started by: manjuWicky
3 Replies
2. Solaris
I am having a brain fart. I have a few potential work-arounds, but the fact that I can't get this string to work is urking me.
nodes:
machine1
machine2
#uname -a
blah blah blah solaris 5.9 machine1 :)
#pwd
/log/arch
find . ! -newer filename -exec 'rcp -p machine2:/log/arch' {} \;... (3 Replies)
Discussion started by: PINGWIN CODER
3 Replies
3. Shell Programming and Scripting
Hi,
my $log = IO::File->new(">$log_file_name");
$log->print("date()."--\n\n\n");
sub process {
my ($sub_dir, $file, $config, $log) = @_;
$log->print("-- Reading $file file\n");
}
my $pm = new Parallel::ForkManager($tc+1);
$pm->run_on_finish( sub { my ($pid, $exit_code,... (1 Reply)
Discussion started by: sandy1028
1 Replies
4. Shell Programming and Scripting
Hi there,
I'm writing a script to restore 3 directories and 3 mysql db's every 24 hours. While writing the script, I came across the thought...
Do I need to pause between executions?
Example:
msql restore1.sql
rm -Rf path1/*
cp -Rf path1/* /restore1
chmod 777 /folder1/cache1
... (2 Replies)
Discussion started by: semiotics101
2 Replies
5. UNIX for Dummies Questions & Answers
Hi ,
What is the diffence between executing the script like
./myscript.ksh
. ./myscript.ksh
I have found 2 difference but could not find the reason
1. If i export a variable in myscript.ksh and execute it like . ./myscript.ksh the i can access the other scripts that are present in... (5 Replies)
Discussion started by: max_hammer
5 Replies
6. Programming
Hello everybody.I want to make clear that i am not going to ask from anybody to build my asignement but i have a big problem. I can't seem to find anywhere ONE good example on C about what i am trying to do:wall:.I think it is simple. All i ask is one example, even a link is fine.
So, i want to... (1 Reply)
Discussion started by: Cuervo
1 Replies
7. Programming
I have an input file with contents like:
5785690|68690|898809
7960789|89709|789789
7669900|87865|659708
7869098|65769|347658
so on..
I need to pass this file to 10 parallely running processes (forking)so that each line is processed by a process and no line is processed twice and write the... (1 Reply)
Discussion started by: rkrish
1 Replies
8. Shell Programming and Scripting
The following is my bash script
-----------------------
#!/bin/bash
exec myscript "$@"
-----------------------
When invoked, the script "myscript" in the exec command
is using the file "/usr/bin/diff"
But, I want the script "myscript"to use the file "/home/bin/diff"
How can I... (1 Reply)
Discussion started by: bsoo
1 Replies
9. Shell Programming and Scripting
I have the following bash script lines in a file named test.sh.
#!/bin/bash
#
# Write Date to cron.log
#
echo "Begin SSI Load $(date +%d%b%y_%T)"
#
# Get the latest rates file for processing.
#
d=$(ls -tr /rms/data/ssi | grep -v "processed" | tail -n 1)
filename=$d
export filename... (3 Replies)
Discussion started by: ginowms
3 Replies
10. UNIX for Beginners Questions & Answers
Hello... And thanks in advance for any help anyone can offer me on my question! I've been doing a lot of reading to try and find my answer... But I haven't had any luck
What I'm trying to understand is where a child process inherits global environment variables from? I understand the exec()... (2 Replies)
Discussion started by: bodisha
2 Replies
LEARN ABOUT NETBSD
setmode
SETMODE(3) BSD Library Functions Manual SETMODE(3)
NAME
getmode, setmode -- modify mode bits
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <unistd.h>
void *
setmode(const char *mode_str);
mode_t
getmode(const void *set, mode_t mode);
DESCRIPTION
The setmode() function accepts a string representation of a file mode change, compiles it to binary form, and returns an abstract representa-
tion that may be passed to getmode(). The string may be an numeric (octal) or symbolic string of the form accepted by chmod(1), and may rep-
resent either an exact mode to set or a change to make to the existing mode.
The getmode() function adjusts the file permission bits given by mode according to the compiled change representation set, and returns the
adjusted mode. While only the permission bits are altered, other parts of the file mode, particularly the type, may be examined.
Because some of the possible symbolic values are defined relative to the file creation mask, setmode() may call umask(2), temporarily chang-
ing the mask. If this occurs, the file creation mask will be restored before setmode() returns. If the calling program changes the value of
its file creation mask after calling setmode(), setmode() must be called again to recompile the mode string if getmode() is to modify future
file modes correctly.
If the mode passed to setmode() is invalid, setmode() returns NULL.
EXAMPLES
The effects of the shell command 'chmod a+x myscript.sh' can be duplicated as follows:
const char *file = "myscript.sh";
struct stat st;
mode_t newmode;
stat(file, &st);
newmode = getmode(setmode("a+x"), st.st_mode);
chmod(file, newmode);
ERRORS
The setmode() function may fail and set errno for any of the errors specified for the library routines malloc(3) or strtol(3). In addition,
setmode() will fail and set errno to:
[EINVAL] The mode argument does not represent a valid mode.
SEE ALSO
chmod(1), stat(2), umask(2), malloc(3)
HISTORY
The getmode() and setmode() functions first appeared in 4.4BSD.
BUGS
Each call to setmode allocates a small amount of memory that there is no correct way to free.
The type of set should really be some opaque struct type used only by these functions rather than void *.
BSD
January 4, 2009 BSD