I have used the wpa_passphrase command and I get something like this:

network={ ssid="blahblah" #psk="moreblahblah" psk=d5e532ecca53ea963e5b3b5521bb3682c53fcf5b6d55f15622027145c795b661 }

I need to copy that "psk=[long string]" to my wpa_supplicant.conf file. How can I select it in order to copy it? And then what command do I use to copy it? Such that in my favourite text editor I can press a paste command to paste it? (ps. I don't have a mouse )

link|improve this question
feedback

5 Answers

if you have a touchpad though, highlight the text and press Ctrl + Shift + C to copy ...

the following resources describe how to copy/paste using keyboard only -- screen/byobu:

How do I integrate Byobu's copy-buffer with that of the system's ?

http://www.samsarin.com/blog/2007/03/11/gnu-screen-working-with-the-scrollback-buffer/

Copy and Paste in Scrollback mode (screen/byobu)

  • Enter scrollback mode: Ctrl+A+[ or in byobu also F7
  • Move the cursor to the start of the text you want to copy, hit spacebar
  • Move the cursor to the end of the text you want to copy and hit spacebar again
  • To paste text, hit Ctrl+A+]
link|improve this answer
feedback

Try this:

wpa_passphrase | awk '/psk/ {print $4}' >> wpa.supplicant.conf

Command should take out the "psk=d5e532ecca53ea963e5b3b5521bb3682c53fcf5b6d55f15622027145c795b661" part and copy it to the end of your wpa.supplicant.conf file. Try changing $4 to $3 or $2 if you don't get the right part of the wpa_passphrase command.

link|improve this answer
feedback

May be not perfect but a workaround. May be you could write the output in a file then go into the file remove unnecessary text and using cat you could append it to wpa_supplicant.conf

Basically your workflow would be:

command > rough

nano rough here delete the unnecessary text and keep just the necessary ones i.e psk

sudo sh -c "cat rough >> wpa_supplicant.conf"

Or may be you could use vim to yank the required text choosing it in visual mode.

P.S. Someone with good knowledge of sed would give you a easier solution than this I think.

link|improve this answer
the sudo sh ... command could be written as: cat rough | sudo tee -a wpa_supplicant.conf. – Lekensteyn Apr 28 '11 at 7:34
feedback

The next sed command will fetch the key (which consists of characters from the hexadecimal set) from the output of wpa_passphrase and put it in a temporary file pass.

wpa_passphrase | sed 's/.*psk=\([0-9a-f]*\).*/\1/' > pass

As you do not have a mouse, you cannot just select and copy it. We'll use the nano texteditor for inserting this pass:

nano wpa_suppliciant.conf

Move to your desired location using your arrow keys and press Insert. Enter the name of the file you've just created, pass, followed by an Enter. Quit & save the result by pressing Ctrl + X and confirm it by entering Y followed by an Enter.

link|improve this answer
feedback

Of course the most common way to do this would be to use a mouse or other pointing device (such as a touchpad). Although it's somewhat excentric, it's possible to copy text without a mouse. (You may of course have a valid reason not use a pointing device.) Check out xclip, as in this answer. Thus you could use:

wpa_passphrase | xclip -sel clip
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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