If you’re like me, you sometimes get an omni-potent feeling when staring down the proverbial ‘barrel’ of the BASH shell. And why shouldn’t you? It’s built-ins have everything you need to conquer the world. In fact, you might even use it to get away with murder. Of course, we’re not here to kill anyone. …We just want to cover our asses when the boss comes looking for our TPS reports.
You are habitually late meeting your deadlines at work. Your boss asks for April’s TPS report and demands that it be completed and in his inbox by Friday, 05/04/12. Friday has come and gone, though luckily your boss was out of town that day. You know that he is still expecting to see a PDF in his inbox, so you use imagemagick to make a phony, 3-page PDF.
Imagemagick has a great tool built into it called convert. We can use that to generate a 3 page PDF easily.
First, install imagemagick, though you probably already have it installed.
sudo apt-get install imagemagick
Now, let’s make the phony document. We will start out by making 3 blank images. In order to elicit the right response from the recipient and pull this off proper, it has to be believable. This command will produce 3 jpegs in portrait mode, with 8×10 dimensions at 300 dpi
convert -size 2550x3300 -density 300 xc:white apriltpsreport1.png
convert -size 2550x3300 -density 300 xc:white apriltpsreport2.png
convert -size 2550x3300 -density 300 xc:white apriltpsreport3.png
If you wants the pages to be in landscape, just reverse the dimensions.
convert -size 3300x2550 -density 300 xc:white apriltpsreport1.png
Next, we can use convert to combine all of these images into a PDF.
convert apriltpsreport* apriltpsreport.pdf
NOTE: If you’ve actually put the hard work into making a real report, and you need to combine all of those elements into a multipage PDF, don’t use the wildcard (*) like I have above. List each image successively in the order you would want it to appear in the document.
Now, here is the full command that will create all of the images, combine them into a PDF, and clean up the mess that it wants to leave behind.
convert -size 2550x3300 -density 300 xc:white apriltpsreport1.png && convert -size 2550x3300 -density 300 xc:white apriltpsreport2.png && convert -size 2550x3300 -density 300 xc:white apriltpsreport3.png && convert apriltpsreport* apriltpsreport.pdf && rm apriltpsreport*.png
Now, we’re not ready to send this file just yet. You see, the boss man is not the sharpest tool in the shed, but at the same time he is desperate to catch you in a surreptitious act. He might have the notion to check the file creation date. If that time is just a minute or two before you sent the email to his inbox, you are toast. This is your chance to make yourself look good. The project was due on the 4th, but as far as he can be concerned, you finished it on the 1st!
touch -d '1 May 2012' apriltpsreport.pdf
Great! Now you’ve successfully modified the file. It will now show that you created it on May the 1st, but since we are playing psychological warfare, we need to consider all things. What does your boss really expect? Well, for starters, he doesn’t expect you to finish things on time. That’s what we are here to overcome- and we did- so what else? If you do finish a project on time, it’s at the last minute. So, this is the command we really should be running…
touch -d '1 May 2012 16:49' apriltpsreport.pdf
There, that’s better. Now he can see that the project was completed at 4:49pm, right before you walked out the door. Though, that might not be enough. What about the last accessed time. You don’t want him to think that you’ve been fooling with it since the first. Let’s fix that.
touch -amt 201205011649 apriltpsreport.pdf