0

I'm very new to programming especially regarding shell scripts and I am trying to create a virtual printer system with 4 simple shell scripts, and in this the user would have virtual credits to be able to print, starting at a base value of 150 and only changed by the commands. These print requests should be stored inside a directory .printer and in this directory there should be a file .cred containing the amount of credits the user has. lpdoc - creates a directory .printer of the user who used the command and checks if he has enough credits and debits them, preventing the use of the command if he doesn't.

#!/bin/bash
cd .. 
mkdir .printer
echo 150 > .printer/.cred

So far all this does is create the .cred file inside the directory .printer but I don't know how to make the actual use of the command.

cancel fil1 [fil 2...] - removes the print requests specified in the command line and should return to the user the credits used

#!/bin/bash
cd ..
rm -r /.printer

Regarding the path to the directory, how would I make it work for any user that ran the command? Since if I specify the user it would only work for that user. Also, by running that command it would delete all the files inside the directory but I only want the specified files from the command.

lpstatus - would show the current requests and their cost in credits, and also the current user credits. For this I have nothing, since I couldn't create the script for lpdoc.

actu [credits] user1 [user2...] - would increase the ammount of credits the specified users have with a default value of 100.

#!/bin/bash
const=100

Tried making an if loop but failed so I deleted it, and all that's there is the set value.

2

0

You must log in to answer this question.

Browse other questions tagged .