need help to understand and write script in fork


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need help to understand and write script in fork
# 1  
Old 10-25-2007
need help to understand and write script in fork

Can anybody help me for writing unix shell scripting on fork();
it will be appreciated, if any body can send me sample, tutorial ...with details.
# 2  
Old 10-25-2007
If you're familiar with C, see this

If you're familiar with Perl, see this
# 3  
Old 10-25-2007
hey thanx, but i am a layman to fork, how my scripts which is shell script use this forking process, do you have sample tutorial with description......
it will be appreciated, if you can teach me fork.
# 4  
Old 10-25-2007
Advanced Bash-Scripting Guide has some information and an example:

http://www.tldp.org/LDP/abs/html/internal.html#FORKREF
# 5  
Old 10-26-2007
hey MA,

THANX A LOT........BUT WILE GOING THRU THE SAMPLE I FOUND THERE IS A WORD pidof , WHAT IS THIS ???? IS THIS A KEYWORD OR SOMETHONG ELSE....IF SO CAN U EXPLAIN PLEASE ......
# 6  
Old 10-26-2007
Quote:
Originally Posted by manas_ranjan
hey MA,

THANX A LOT........BUT WILE GOING THRU THE SAMPLE I FOUND THERE IS A WORD pidof , WHAT IS THIS ???? IS THIS A KEYWORD OR SOMETHONG ELSE....IF SO CAN U EXPLAIN PLEASE ......
pidof finds the process ID of a running program. A good way to understand things is to try them out: go to your command shell and execute "pidof sh" or "pidof bash".

In a script, you could use "$$" to get the Process ID of the script instance but pidof has the extra advantage of giving you *all* process ids of instances of the script.

Last edited by neked; 10-26-2007 at 11:37 AM.. Reason: added some information about pidof
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Help me understand this script

#!/bin/awk -f BEGIN {i=1;file="modified.txt"} { if ($0 !~ /^DS:/) {print $0 >> file} else { if ($0 ~ /^DS:/) {print "DS: ",i >> file;if (i==8) {i=1} else {i++}}; } } END {gzip file} Can someone explain to me how this above script works, I got it from a friend but not able... (3 Replies)
Discussion started by: Kamesh G
3 Replies

2. Shell Programming and Scripting

Help to understand a script

Hello world! Can someone please explain me how this code works? I'ts supposed to find words in a dictionary and show the anagrams of the words. { part = word2key($1) data = $1 } function word2key(word, a, i, x, result) { x = split(word, a, "") asort(a) ... (1 Reply)
Discussion started by: jose2802
1 Replies

3. UNIX for Dummies Questions & Answers

Need to understand shell script

Hello, Can someone please help me understand the shell script below for installing Jboss EAP 6? It is from jboss-as-standalone.sh, what does the highlighted code mean? # Load Java configuration. && . /etc/java/java.conf export JAVA_HOME Thanks! (4 Replies)
Discussion started by: learnix
4 Replies

4. Shell Programming and Scripting

Need to understand the script pls help

Can u please explain what it is doing #!/bin/sh fullyear=`/home/local/bin/datemmdd 1`"."`date +%Y` uehist=/u05/home/celldba/utility/ue/prod/history echo $fullyear cd $uehist ls -ltr pwroutages.master.$fullyear* | awk '{print $9}' > /u01/home/celldba/tmp/pwroutages_master_all_tmp while... (2 Replies)
Discussion started by: raopatwari
2 Replies

5. Shell Programming and Scripting

Help to understand the script

Hi All; Is there anybody can explain this script please? trap 'C_logmsg "F" "CNTL/c OS signal trapped, Script ${G_SCRIPTNAME] terminated"; exit 1' 2 trap 'C_logmsg "F" "Kill Job Event sent from the Console, Script ${G_SCRIPTNAME] terminated"; exit 1' 15 (3 Replies)
Discussion started by: thankbe
3 Replies

6. Shell Programming and Scripting

Can't understand the script

I am relatively new to Shell Scripting. I can't understand the following two scripts. Can someone please spare a minute to explain? 1) content s of file a are (021) 654-1234 sed 's/(//g;s/)//g;s/ /-/g' a 021-654-1234 2)cut -d: -f1,3,7 /etc/passwd |sort -t: +1n gives error (3 Replies)
Discussion started by: shahdharmit
3 Replies

7. UNIX for Dummies Questions & Answers

How can i use fork,sleep,wait and write in a process with father and son..??

Hi.. I was unable to do (gcc code) which refers to the fork,wait,sleep and write.. what i want to do: A process of father create (fork) a son and will sleep 90 seconds..After this, son process create a grandchild and will sleep 60 seconds..Grandchild process will sleep for 30 seconds..After... (3 Replies)
Discussion started by: gumlucin
3 Replies

8. UNIX for Dummies Questions & Answers

How to write a script by fork() in unix

Hello to UNIX Champs, Can any body help me out to write the script using fork() thru shell scripting.....i am a layman to fork(), so please give me the link or any scripts which will help me out to know the details about fork. (1 Reply)
Discussion started by: manas_ranjan
1 Replies

9. Programming

fork/exec clobbers write. I need ideas why...

On my *nix box, I have a telegram program. When I go like tel person "la\nla\nla\n" the person sees "la\nla\nla\n" However, when I have a program that forks and execs tel like: pid = fork(); if (pid < 0) { perror("fork failed"); exit(EXIT_FAILURE); } if (pid == 0) {... (7 Replies)
Discussion started by: frequency8
7 Replies
Login or Register to Ask a Question