Copying raw text from a grep to paste in an email - grep

I'm running a VM with Debian 7.0 x64 and need to troubleshoot something with a provider, so when I run a grep command, the console outputs a long report. I need to copy all of that text that has been output and place in the body of an email, or post directly on another forum board. I'm sure the solution must be simple, but I can't find it in searching online. I see suggestions for right-clicking with the mouse but my VM console doesn't response to mouse clicks, and then I see suggestions for copying and modifying files within the console, but as I said above I just need to take the raw text to paste elsewhere.
Thanks for the help!!!

the easiest way would be to save the output to a file and attach that to your email. (personally i hate emails that have inlined long error-logs without good cuase - like annotations).
this would also allow you to compress the file before attaching it, reducing the size considerably (as text compresses quite nicely).
if this is not an option, there is xclip, which reads from stdin and puts that into a selection.
$ ls | xclip
allows you to paste (with your middle-mousebutton) the contents of a dir.
if you must use Ctrl-v for pasting, you can also do:
$ ls | xclip -selection c

Related

Generate markdown docs with rustdoc?

Is there any way to generate a single markdown file in doc/ from the /// comments?
Multiple markdown files (doc/main.md, doc/foo.md, etc) would be nice too.
I'm new to rust, and while the generated HTML documentation is nice, I mostly live on the command line and really don't want to be switching between my terminal and a web browser just to read the docs. That breaks the flow and takes me out of the zone. Also, md is easily converted to man pages, or to TeX for printed or PDF docs.
(I'm used to suspending vim with Ctrl-Z or using another terminal tab, and running man or perldoc or pydoc etc. Text-mode browsers like lynx nor links are not good options for me - navigation is clumsy, the output is ugly on my 200+ column terminals windows if i forget to use the -width option, and neither support javascript)
cargo-readme might work for you. You run cargo readme -i foo.rs > FOO.md and it populates FOO.md with the contents of the doc comments from foo.rs. Found it via reddit.

Modify basic files used with gwbasic

I have a batch file which launches other .bas files with the help of gwbasic.
Here is the code of the batch file:
graphics
cd basic
gwbasic menut-hp/d
cd \
Then I have the possibility by typing 1 or 2 etc + ENTER to choose which program i want to run. The programs are located in the same directory as my batch file. The programs are xxx.BAS files.
The problem is:
I have a piece of software written in GWBASIC that currently is set up to just print locally to LPT1.
When I disconnect the local printer, the software (gwbasic i guess) sends automatically the things to print to the network printer.
The result is that a lot of A4 papers come out with only a few lines written.
On the local printer, the printer only printed when i exited the batch program.
On the network printer, it's like its non stop synchronizing, and not only when i exit the batch program.
I see 2 solutions:
manage to put a tempo for the printing on the network printer (to refresh every 2 minutes for example)
or try to add a line in the .BAS files, to save the text in a .txt of .pdf file, instead of printing it.. or print it in a pdf file.
I have almost no idea how gwbasic works, even after some researches.
Moreover, i haven't managed to view (and modify) the code of the .BAS files
Sorry for my bad english,
If anyone has any idea, it would help me a lot!
Thank you very much :)
Maybe later, but I enjoy scripting with BASIC and CONSOLE APP.
I recommend you run a command BAT before you BAS code to get default printer
wmic printer get name,default | find "TRUE" > Printer.txt
With this linen you get the similar response into Printer.txt
TRUE Microsoft Print to PDF
After that, in your BAS code, read them and validate printer name or discard network printer before print.
Happy coding!

xcode run script on deployment

I have a game which has xml files in it. My game works on iPad and on iPhone, and i need to perform some changes in these xml files accordingly, but the xml files are original and i do not want them changed, so what i want is have my xml files changed automatically at compile time. For this purpose i have a ruby script which does what i need.
Let's say this script is level_converter.rb
which i can execute(in terminal) as follows:
for f in Resources/*.xml; do ruby level_converter.rb "$f"; done
So i added this code to Build Phases to Run Script this way and this does work as expected, it does change all the xml files properly, BUT ofcourse it changes the original xml files in the resources foler. So say if i run twice - i'll have these files changed twice. What i want is these files stay not changed but only those deployed should change. So i need some kind of $(PROJECT_DISTRIBUTION_AND_DEVELOPEMENT_TEMP_FOLDER) or something like that instead of simply Resorces/*.xml eg.
for f in $(PROJ_DISTRIB_AND_DEV_TMP_FLDE)/*.xml; do ruby level_converter.rb "$f"; done
edit: must be im not that clear with the question, so i've rephrased it
Regards,
Igor
i was able to achieve what i wanted, here is the script:
PROJ_DIR=${PWD}
echo "Converting xml files..."
for f in "${CODESIGNING_FOLDER_PATH}/"*.xml
do
cp $PROJ_DIR/Resources/"${f##*/}" "$f"
ruby level_converter.rb "$f" $PROJ_DIR/key_hash;
done
exit 0;
So i used this ${CODESIGNING_FOLDER_PATH} variable.
explanation:
the for iterates the *.xml files in the destination directory
cp $PROJ_DIR/Resources/"${f##*/}" "$f": as far as xcode only copies resources only if they were changed i have to manually copy the xml files to prevent them being converted more then once - so the converter is executed each build and so it should have original files in place to convert
ruby level_converter.rb "$f" $PROJ_DIR/key_hash; : this simply executes the script
this does what i wan't but there are drawbacks/doubts:
from time to time i get a warning that the signed resources where changed or removed (well that doesn't surprise me though). Maybe there is a way to supress this? It does stop the app being sandboxed and i have to build again and hope there will be no warning next time. Lucky me it does not appear often
building takes much longer, it would still be nice to figure if the original files where changed and only execute the script if necessary
i still think there should be some "proper" way to achieve what i wanted
i am not sure i've picked up the variable CODESIGNING_FOLDER_PATH correctly, maybe i should use another one
edit: i moved the run script to be run before compiling source code, and didn't get any warnings about signed resources changed since then. Wandering if that's the cause

How does vi editor remember current line of the previous file

Suppose I am reading a file in vi editor. I am at line number 50 and I quit. After some time I reopen the file in vi editor. I notice that the cursor is at the same line where I was before closing the file.
How does VI editor remember this?
Don't know about plain old vi. vim, however, saves the current line number of the files you edit with it in a file called .viminfo in your home directory. At least, that's what it does in Linux.
You can see this behavior in many programs. You close your IDE and when you reopen it, it opens your last project. Your can kill your firefox and when you reopen it, you get all your pages reloaded.
It is simple, they save it somewhere for themselves.
One of the common places to save these information in Windows-y applications is the registry. You can run regedt32 in your windows and see all those data there. With Linux-y applications, it is common to create a hidden file in your home (~). You can go to your home directory in your Linux and open file .bash_history and see your old bash commands that you can access with the Up Arrow key
Vi in particular? Definitely has a file somewhere.

Need help opening printer spool shadow file (.SHD) that is locked

I'm interested in some information inside a shadow file (.shd) located inside the windows print spooling directory "C:\Windows\System32\spool\PRINTERS". Every time a print job is started, a spool file (.spl) and a shadow file (.shd) are created in that directory. So far I have been successful in detecting when a print job has started, and have been able to pause that print job. If you don't pause the job, the files eventually make their way to the printer and then are deleted by windows.
My problem is. I cannot open the .SHD files because they are locked in such a way that you can not read them while they are open by the sprint spooler. I've even tried going to the file in windows explorer and simply copying the file to another file, and that didn't work either. The .SPL spool files I can open though. I simply wait, and fairly quickly the spooler release that file. For the shadow file though, it permanently holds on to this file. Unfortunately, its the one I need.
The line of code I'm using specifically to open the file is as follows:
m_spoolJobStream = new FileStream(spoolFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
The IOException I get is:
The process cannot access the file 'C:\Windows\system32\spool\PRINTERS\FP00083.SHD' because it is being used by another process.
So yes, it is being used by another process. Its being used by the window's print spooler service. But I don't think there is anything I can do about that. All I want to do is read the file. I don't want to make any changes to it. Is there anything I can do here or am I just screwed?
Check the option: "Keep printed documents" (if you have HP printer) and then see your spool file folder, both shadow and spool files would be there.
Well, I did not find a way around this problem. I suspect there is no solution for this and it is by design. However I did find another way to get the information I wanted (at least it seems so thus far).
I'm using the FindNextPrinterChangeNotification() routine out of the winspool.drv library. This guy returns a pointer to a PRINTER_NOTIFY_INFO structure, which in turn contains an array of PRINTER_NOTIFY_INFO_DATA structures. Within that array, there is an element with its "Field" member marked as "JOB_NOTIFY_FIELD_DEVMODE". This element contains a fairly large structure of type DEVMODE. The structure is explained by M$ here http://msdn.microsoft.com/en-us/library/dd183565%28v=vs.85%29.aspx . This structure looks like it contains what I'm looking for and apparently is wrapped up in the .SHD file anyways according to this page http://www.undocprint.org/formats/winspool/shd. I'd like to know what else is in that .SHD file, but I still can't open it because its locked while the job is paused, and I suspect that it stays locked until the job is complete. Oh well, I think my new solution is more elegant anyways.
Just make sure you pause the job in the spool on BOTH your box and the server, then you should be able to copy/open/move the shd file just like you can the spl file. Worked for me, anyway...
This works for me:
- Hang your printer (e.g. jam the paper)
- Print and observe .SHD and .SPL being created
- Stop Print Spooler
- Open the file
The problem might be the FileShare.ReadWrite parameter. You're asking to read and write on the file and maybe that's why you get an error. You should try asking for read-only permission.

Resources