Protect what matters – even after you're gone. Make a plan for your digital legacy today.
Forum Discussion
Former Member
4 years ago[ERROR]This command is meant to be used with your shell's eval function.
Hello,
started using CLIv2 and I have a problem with the script I am creating right now, even tho my colleague is working with the same script and it works for him fine (He is using Linux, I am using MacOS)
```
import subprocess
import json
import os
import sys
import pexpect
import operator
password = "$password$"
signin_process = None
try:
signin_process = pexpect.spawn('op signin -f --config $MyHomeDir$/.config/op/')
signin_process.expect("Enter the password*")
signin_process.sendline(password)
signin_process.expect(pexpect.EOF, timeout=10)
signin_process.close()
except Exception as e:
print(e)
signin_token = bytes.decode(signin_process.before, "utf-8").split("\r\n")[1].split(" ")[1].strip()
vaults = pexpect.run('/usr/local/bin/op vault list --config $MyHomeDir$/.config/op/', env={signin_token.split('=')[0].replace('"', ''): signin_token.split('=')[1].replace('"', '')})
print(vaults)
```
After debugging it finds this as a problem:
bytes.decode(signin_process.before, "utf-8")
' for $USER$ at $DOMAIN$.1password.com: \r\nexport OP_SESSION_$USERID$="$SIGNINTOKEN$"\r\n# This command is meant to be used with your shell\'s eval function.\r\n# Run \'eval $(op signin $domain$)\' to sign in to your 1Password account.\r\n# Use the --raw flag to only output the session token.\r\n'
Have you got an idea what could be solution for me?
Thank you
1Password Version: Not Provided
Extension Version: Not Provided
OS Version: Not Provided
1 Reply
- Former Member
Hey @patrikst,
From what I can see, the problem in the script above is that you expect to be outputted the token from the command, when, in fact, the help-text providing instructions on how to export the session token is outputted.
The first thing that comes to mind here is to add the--rawflag to theop signincommand. This should ensure that the only thing outputted is the session token.
Let me know if this helps! Looking forward to hearing from you.Best,
Horia