Perhaps a more explicit version of the previous answer. If the file you are accessing is called filename, and you are working in the same directory ... (if you use different directories, then obviously replace the file name with the whole path)
write("Attempting to get lock", stderr()) system("lockfile filename.lock") \
guest source share