Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 )

share|improve this question
add comment

5 Answers 5

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+]
share|improve this answer
4  
This information isn't quite right for byobu. Copy in byobu is Spacebar then Enter, per the byobu manual. Differs slightly from screen in that way. I only mention it here because this post happens to rank very highly on google for "copy/paste in byobu". –  philo Aug 18 '12 at 1:45
add comment

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.

share|improve this answer
add comment

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.

share|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
add comment

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.

share|improve this answer
add comment

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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