1,105,363 Community Members

shell script

Member Avatar
Light Poster
28 posts since Aug 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]

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


#! /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
while [ $count -lt 200 ]      # still loop 200 times
   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
Member Avatar
Veteran Poster
1,144 posts since Apr 2010
Reputation Points: 303 [?]
Q&As Helped to Solve: 264 [?]
Skill Endorsements: 3 [?]

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?

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