You are not logged in.

#1 2022-11-08 00:44:49

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,168

[solved]How to have pass read data from a file?

I've got a bunch of passwords (with URLS and usernames) exported from chromium. I want to put these into pass's database. I've split the original file up so that each file contains

<password>
URL: <url>
Username: <username>

and generally has some <name> according to the website.

So I want to use

pass insert --multiline web/<name> ...

to add them to the database, but I don't want to do this interactively. I want to take the data from the file.

I know this is probably a stupid question, but how can I do this?

Last edited by cfr (2022-11-08 02:04:51)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#2 2022-11-08 00:57:13

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [solved]How to have pass read data from a file?

This would be a programming and scripting question; you'll need a loop that reads the file name, creates the corresponding file with pass and then writes the details.

This would be tedious. You could jerry rig a tool like this to do it: https://github.com/roddhjav/pass-import

# edit: ^ by converting your plain text files to a csv, would be the simplest approach.

Last edited by jasonwryan (2022-11-08 00:59:33)


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2022-11-08 02:04:32

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,168

Re: [solved]How to have pass read data from a file?

Thanks. I just re-exported them from chromium, installed pass-import from AUR and fiddled a bit until I got the syntax right. I thought pass-import was for other password managers. I didn't realise that included password managers in browsers.

I'm still curious how I could script pass to use information from a file, because it seems a useful thing to be able to do in other contexts.

Apologies for posting in the wrong place. I realised after I'd done it scripting would have been more appropriate.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#4 2022-11-08 02:19:16

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [solved]How to have pass read data from a file?

cfr wrote:

I'm still curious how I could script pass to use information from a file, because it seems a useful thing to be able to do in other contexts.

You could tweak this: https://unix.stackexchange.com/question … rd-manager


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#5 2022-11-08 02:26:52

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,168

Re: [solved]How to have pass read data from a file?

jasonwryan wrote:

Thanks, but I was more wondering how to substitute input from a file when something expects interactive input. So you can't just say

pass insert --multiline <name-in-store> << <file-with-data>

because pass expects you to input something manually.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#6 2022-11-08 02:36:57

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [solved]How to have pass read data from a file?

Yeah, that's why I was suggesting the loop: first you have to create the directory structure and files, and then write all the details.

So, read your file into an array, and then run two pass loops. Ugly, but I don't see any other way native to pass itself.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#7 2022-11-08 02:49:25

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,611

Re: [solved]How to have pass read data from a file?

jasonwryan wrote:

jerry rig

Mixed metaphor?  I thought it was Jerry Built or Jury Rigged meaning slightly different things.  Or is this a different side of the world thing?
Anyway, always good to see you.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#8 2022-11-08 03:37:14

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,168

Re: [solved]How to have pass read data from a file?

jasonwryan wrote:

Yeah, that's why I was suggesting the loop: first you have to create the directory structure and files, and then write all the details.

So, read your file into an array, and then run two pass loops. Ugly, but I don't see any other way native to pass itself.

Ah, OK. So I'm not missing some obvious way of feeding stuff to a command which doesn't expect anything but interactive input? I always assumed there must be some neat way of doing this I just didn't know.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

Board footer

Powered by FluxBB