Copy text from a file from VI editor to Windows clipboard

Copy text from a file from VI editor to Windows clipboard,
I mean copy entire file in vi editor to notepad.

From windows use command prompt and do telnet to the unix system.
display the contents using cat. to copy the contents of the file right click on command prompt and open properties. select quick edit mode in edit options and select ok. select the contents of the file using mouse and press enter. now the text is in your windows clipboard. if the file is too large then ftp the file to your system.

What I used is PuTTy.
How to do it?
tkx

PuTTY doesn't have a copy button. It doesn't need one, select any text in PuTTY and it's immediately copied to the clipboard.

You can highlight the text in PuTTy and that should copy the data to your clipboard. Then just paste it into notepad. As far as the entire file goes, I think you would have to highlight it all with your mouse. I don't believe you can copy the file to your windows clipboard using 'vi' on the remote machine.

or you could simply forward the whole file to your mailbox (in windows or anywhere you have your email client) -using this unix command "more {filename} | mailx {you@email.tld}" - of course larger files are not surgested to mail forward (100 MB+). Are the file(s) that big FTP transfer are also my surgestion to you.

Hope you make it work

You can highlight the text in PuTTy and that should copy the data to your clipboard.

The entire file contains several pages.I can only highlight one page,the mouse cannot scrool down.

using this unix command "more {filename} | mailx {you@email.tld}" 

-bash: mailx: command not found

What happened?

Using Putty ... .to copy whole contains to your clipboard then ... what you do is ...

  1. Clear the screen ..

  2. Clear the scrollback by right click on the top bar and select the option "clear scrollback".

  3. From the same option you will find "change settings" --> select this option and againg select "window" option where specify the huge no. say 99999 in no. line for scrollback where it is 200 by default.

  4. Now run the file by using the cat <filename>

  5. Right click on the top bar and select the "copy all to clipboard"

  6. paste it in the notepad.

you get file in the other way also.

  1. You can select the "logging " -> and select the radio button "Log all session output" in Session logging.
  2. In the log file name .. specify the log file location by clicking the browse button.
  3. Now run the file by cat <filename>.
  4. After the file contains end. you can see the the log file which you specified in the log file.

if any questions pls feel free to ask ...

thanks
Satish

As long as it doesn't exceed the size of the putty buffer (which you can increase), you can just cat the file, use the slider bar and go to the top, then highlight the top of the file and drag to the bottom. Ctrl+Ins will capture the highlighted text to your clipboard which can then be pasted into notepad. You may not need to use Ctrl+Ins if it's in the buffer automatically. It depends on the version of Putty or perhaps a configuration option since it doesn't always work for me.

mailx isn't in your path or you don't have it installed (don't know what version of unix you're using). Try using "mail" instead or check /bin, /usr/bin, /sbin, /usr/sbin, /usr/local/bin and see if you can find one of the "mail" programs. Then just add the path and it'll work.

Carl

Thans everybody:
Very helpful.

But where can I find the path of mailx?
Do I need to copy it into my subfolder once I find it?

type mailx #gives path of mailx

You don't say what version of unix you're accessing so you can either hunt through the paths I posted earlier or use one of the utilities to hunt for it. For example, on Solaris (my main unix),

$ grep mailx /var/sadm/install/contents
/etc/mail/mailx.rc e mailxrc 0644 root bin 1829 37709 947116850 SUNWcsr
/usr/bin/mailx f none 2511 root mail 126880 47389 1003406180 SUNWcsu
/usr/share/lib/mailx d none 0755 root bin SUNWcsu
/usr/share/lib/mailx/mailx.help f none 0644 root bin 2989 41016 947116849 SUNWcsu
/usr/share/lib/mailx/mailx.help.~ f none 0644 root bin 1064 23687 947116850 SUNWcsu
/usr/share/man/sman1/mailx.1 f none 0444 bin bin 104155 49322 944774393 SUNWman
/usr/ucb/Mail=../bin/mailx s none SUNWscpu
/usr/ucb/mail=../bin/mailx s none SUNWscpu

So I know that mailx is in /usr/bin.

On Linux boxes (the couple I checked anyway), there is no mailx program. The mail program is in /bin

On AIX mailx is in /usr/bin just like Solaris

On HP-UX mailx is in /usr/bin.

So if the system is running linux, use:

/bin/mail -s "testing" you@email.tld < (filename)

If the system is using a non-Linux Unix, you'd do this instead:

/usr/bin/mailx -s "testing" you@email.tld < (filename)

Of course you must replace you@email.tld with a valid e-mail address that you receive e-mail from and (filename) must be replaced with the name of the file you're trying to send to yourself.

Good luck.

Carl

or trying to find the mailx on your system you could use the find command "find [search-destination i.e. "/"] -name mailx"

  • only this demands you to have the find command embedded on your system, eventhough this is pretty comon on most unixes.

Otherwise you could use "mail" as someone surgested, another one is sendmail which is also possible that you have.

  • note that either mailer could be used with a number of parameters, above/below is only shown the most simplified you need; "more {filename} | mailx {you@email.tld}" ~ you could also use the cat instead of more, they do the same in this matter...

  • I hope all these surgestions points you out to a solution for your problem.

ps. Putty is very good dump terminal, and note that you are able to configure it in numerous ways, that could help you out while connected to a unix shell.

//congo :cool:

to find mailx or any thing else, just type

find / -name "what you are looking for" 2>/dev/null

2>/dev/null is used to prevent the errors to be displayed and you will see only what you are looking for.

the above operation may take a while.

Hope that helped