We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,344 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

shell script

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
2
Contributors
1
Reply
18 Hours
Discussion Span
2 Years Ago
Last Updated
2
Views
Josue198s
Light Poster
28 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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?

griswolf
Veteran Poster
1,176 posts since Apr 2010
Reputation Points: 344
Solved Threads: 262
Skill Endorsements: 1

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0622 seconds using 2.7MB