Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I make it work on OSx? #2

Open
magnuswikhog opened this issue Feb 21, 2021 · 4 comments
Open

How can I make it work on OSx? #2

magnuswikhog opened this issue Feb 21, 2021 · 4 comments

Comments

@magnuswikhog
Copy link

When running this on OSx, it doesn't export any attachments.

It seems that the regex that extracts the id's doesn't work as expected. When I try running

lpass ls | sed -n "s/^.*id:\s*\([0-9]*\).*$/\1/p"

directly in the terminal, it just returns a bunch of empty lines. I've tried experimenting to get it to work, but didn't succeed.

Any ideas?

@riezen
Copy link

riezen commented Feb 22, 2021

Magnus,

I was also unable to get the script to work on Big Sur.

I wrote a stand-alone python 3.7 script as a replacement and managed to get all the attachments.

It's not field tested but I can put it on GitHub if you need it.

Stewart

@magnuswikhog
Copy link
Author

Thanks!

However, I already exported my attachments. I ended up just extracting the ID's from lpass ls manually on regexr.com, saved them in a text file and edited the download script, replacing

for id in `lpass ls | sed -n "s/^.*id:\s*\([0-9]*\).*$/\1/p"`; do

with

for id in `cat ../lpass-ids.txt`; do

This works fine for a one-time export, but your Python script might be useful for others who want full automation on OSx.

@bmulholland
Copy link

bmulholland commented Apr 30, 2021

After some experimenting and a newfound hate of macOS' sed implementation, I got it mostly working by changing line 6 to:

for id in `lpass ls | sed -E -n "s/^.*id:[[:space:]]*([0-9]*).*$/\1/p"`; do

In short: -E is needed for sed on macOS to have even a passing semblance to regex,\s isn't supported even with that, and escaping brackets for match groups is not needed when using -E.

There's still a bug where the saved filenames stop at a space (e.g. "Test File.txt" is saved as "Test"). I just went and manually fixed the filenames by checking the items in Lastpass' Vault.

@wally-crunk
Copy link

The script (as currently posted) is not compatible with the macOS (OSX) (Mac OS X) sed, which is from BSD.
The sed from GNU-Linux operates differently.

I fixed it this way:

  • [install homebrew from brew.sh]
  • brew install gsed
  • [find and replace sed with gsed]
  • [rerun the script]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants