1,105,363 Community Members

shell script

Member Avatar
Josue198s
Light Poster
28 posts since Aug 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
-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
Member Avatar
griswolf
Veteran Poster
1,144 posts since Apr 2010
Reputation Points: 303 [?]
Q&As Helped to Solve: 264 [?]
Skill Endorsements: 3 [?]
 
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 three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: