Script has different output when called from python then when called from bash

Question:

I am making a tool so users can sink changelogs from new releases on perforce.
A user with certain rights has to login to download those logs. I need to get the p4 OAuth URL that returns when the p4 login command is ran.
This is what the code looks like in bash

p4 set P4PORT=ssl:XXXXXXXX
p4 set P4USER=XXXXXXXXX
p4 login > XXXXXXXX/temp/url.txt 2>&1 &

and that worked just fine. The url was printed out in the url.txt file.
I load this script as a template using python and write a new file with some changes, a number here a name there. I then call this script and then read the url from the file, but when I call it from my python code using

subprocess.run(['bash','XXXXXXXXXX/load_credentals.sh'])

A file url.txt is created, but it is empty.
I blocked out the file paths and ssh domain name for privacy reasons.

Asked By: James Ayres

||

Answers:

When loading and making edits to the template I forgot to add new lines when building the new file.
I was doing

with open('filename') as file:
    file.write('blah')

instead of

with open('filename') as file:
    file.write('blah n')
Answered By: James Ayres
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.