1.11M Members

shell script

 
-1
 

hi guys please help writing this shell script in C..please

count2:

#! /bin/sh
# count2 also increments and appends a value to the numbers file
# but only when it can successfully create a new hard link to the numbers file
 
count=0
while [ $count -lt 200 ]      # still loop 200 times
do
   count=`expr $count + 1`    # increment the loop counter
   if ln numbers numbers.lock # try to enter the critical region
   then                       # in this case, ln is similar to TSL
      n=`tail -1 numbers`     # get the last number to increment
      expr $n + 1 >> numbers  # increment it and append it to the file
      rm numbers.lock         # exit the critical region
   fi                         # Note that if the ln was unsuccessful, we don't
                              # do busy waiting, but just continue looping
done
 
0
 

Do you want a C program that acts like this Bourne shell script? Or a csh script that acts like this sh script?

Either way, you need to start the work and post your code, possibly not yet running / compiling. Be sure to show the full errors if you have them.

What is the point of this code?

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: