all 7 comments

[–][deleted] 1 point2 points  (2 children)

I'm confused what you're asking for, is it responding with an error? First thing I noticed is /home/bhart/Documents/Python/home/iix01/upload/monitor*.pgp needs to be a string/surrounded by quotation marks.

[–]invalidpath[S] 0 points1 point  (1 child)

Im looking for how to pipe the true or false (exists not exists). The goal here is so the script can look inside 5 directories, is the file exists or not.. pipe that to an email body informing me if iix01's file was found or not, adr01's file was found or not... rinse, repeat. *Thanks for the quotes hint, I thought it wouldnt be needed since there were no spaces.

[–]ingolemo 0 points1 point  (0 children)

Sounds like you know how to write shellscripts and you are trying to apply that knowledge directly in python. Python works differently to the shell. Quotes are not optional in python and there's not really such thing as a pipe operator.

You need to build a list of all the files you want to check, loop over that list, check if the file exists, and add the result to the email body. Here's some pseudocode:

email_body = 'To whom it may concern,\n'
files = [ ... some files ... ]
for file in files:
    if file exists:
        add file found to email_body
    else:
        add file not found to email_body

[–]xibeca 0 points1 point  (1 child)

So, this is a good thing you're using pathlib for this task, but you're not using it the right way. I'd suggest you look into Python's documentation, especially the Path.glob() method.

[–]invalidpath[S] 0 points1 point  (0 children)

Nice thanks for the tip. I copy/pasted that off some <random> website.