0

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.

3
  • This is the kind of situation where using syscall-tracing tools to compare both invocations and figure out what's different in practice is appropriate. Until you figure out where they diverge, you don't know how to build a minimal reproducible example that lets us create the problem ourselves, because you don't know what variables are differing between the usage modes. Commented Sep 17, 2021 at 22:22
  • I personally strongly suggest sysdig, but if installing kernel modules isn't going to fly in your environment, strace -f is better than nothing. Dig into what the three p4 calls actually do and where they fail, and you'll be in a better place to ask a question about the specific failure mode. Commented Sep 17, 2021 at 22:24
  • 2
    BTW, one thing I do recommend would be to log more aggressively. If you start your bash script with exec >/tmp/p4-login-$$.log 2>&1; set -x (after the shebang, of course), you'll have something logged, even if that something just shows what the p4 commands that are being invoked are. Commented Sep 17, 2021 at 22:35

1 Answer 1

0

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')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.