Bash- file names with associated file content
I am working on another optional project for my Linux class.
The basic idea is a bucket brigade. Two scripts are working together to spin off a variable number of instances of a process that hands a file from one to the next... one of the processes generates the bucket files with a random number 1 - 5 for "gallons" another interacts with the "fire" file. The rest are just handing the content of the bucket files down the line. The part I am having trouble with is generating a report on the status of the whole thing while it is still running. I want to be able to list the current bucket.* files that exist and the contents of them. They will each only contain a random number between 1 and 5. It seems like there should be a tool that does this sort of thing simply but I don't know what it would be. I got close with this: Code:
ls | grep bucket. > .current.buckets |
Quote:
Quote:
Code:
BUCKETS=0; GALLONS=0 Code:
incr() { ((BUCKETS++)); GALLONS=$[${GALLONS}+$1]; } Code:
echo "Passing ${BUCKETS} buckets containing ${GALLONS}" |
Well I certainly can post the scripts as they are. I am new at this so they are probably not extremely clear or the best way of doing things... But I have got them running fairly well except for the one hitch. I could actually leave it off and just report the number of bucket files there are and which ones they are easily. But I wanted to add the content of each bucket file to the report.
The brig script is the primary script. The passer script is used by the brig script to instantiate passer processes. I realize these are kinda sloppy... I didn't really start with a plan but just built in one feature at a time. There are some artefacts from testing still in there. I know the variables are a bit sloppy too. I didn't know how many I was going to use. I got a bit carried away with sending errors to /dev/null. When running the script with large numbers of passers and big fire values many processes run out of order and it really wasn't important to know about the errors when it still worked. I also wanted to make sure all the extra files were removed so I built in quite a bit of redundancy, especially with removing the buckets. brig: Code:
#!/bin/bash passer: Code:
#!/bin/bash So what I want is to be able to type "$ brig status" while the passers are still passing bucket files and have information about which buckets are active at the time and what they have in them. One or the other piece of information is easy to do but getting them to work together is what I can't figure out. |
Quote:
|
Ya I don't know what happened. I was copy-pasting several lines at a time from nano because I don't know how to copy an entire nano file content to clipboard, I must have missed some lines... I do have a status case set up. Edit: oh wait, it is in there above the quit case below the alarm case. But it is so sloppy I couldn't even find it for a while lol. Obviously I have a lot of work to do learning to keep things a bit more organized.
Anyway, I was able to get what I wanted for my program with some help from my professor. The code that did what I want is: Code:
for bucket in $(ls bucket.?) |
All times are GMT -5. The time now is 02:48 PM. |