command-line

Combining two executables

I have a command line executable that alters some bits in a file that i want to use from my program. Is it possible to create my own executable that uses this tool and distribute only one executable? [edit] Clarification: The command line tool takes an offset and some bits and changes the bits at this offset in a given file. So I want ...

Dealing with command line arguments and Spring

When I'm writing a Spring command line application which parses command line arguments, how do I pass them to Spring? Would I want to have my main() structured so that it first parses the command line args and then inits Spring? Even so, how would it pass the object holding the parsed args to Spring? ...

Stop and Start a service via batch or cmd file?

How can I script a bat or cmd to stop and start a service reliably with error checking (or let me know that it wasn't successful for whatever reason)? ...

How can I load the contents of a text file into a batch file variable?

I need to be able to load the entire contents of a text file and load it into a variable for further processing. How can I do that? Here's what I did thanks to Roman Odaisky's answer. SetLocal EnableDelayedExpansion set content= for /F "delims=" %%i in (test.txt) do set content=!content! %%i echo %content% EndLocal ...

How can I script a no-cost notification of batch file errors/returns?

I have a problem with stopping a service and starting it again and want to be notified when the process runs and let me know what the result is. Here's the scenario, I have a text file output of an "sc" command. I want to send that file but not as an attachment. Also, I want to see the initial status quickly in the subject of the ema...

How to launch windows regedit with certain path?

How to launch windows regedit with certain path located, like "HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0", so I don't have to do the clicking. What's the command line argument to do this? Or Any place to find the explanation of regedit switches? ...

Colored grep?

Sometimes coloring a logfile or other gives a good overview when looking for stuff and behaviors I just saw that grep have a coloring feature grep -C 99999 --color <regexp> <filename> What other methods are there? ...

Saving 'tree /f /a" results to a textfile with unicode support

I'm trying to use the tree command in a windows commandline to generate a text file listing the contents of a directory but when I pipe the output the unicode characters get stuffed up. Here is the command I am using: tree /f /a > output.txt The results in the console window are fine: \---Erika szobája cover.jpg Eri...

How to create a file with a given size in Linux?

For testing purposes I have to generate a file of a certain size (to test an upload limit). What is a command to create a file of a certain size on Linux? ...

MSBuild directory structure limit workarounds

Does anyone have a method to overcome the 260 character limit of the MSBuild tool for building Visual Studio projects and solutions from the command line? I'm trying to get the build automated using CruiseControl (CruiseControl.NET isn't an option, so I'm trying to tie it into normal ant scripts) and I keep on running into problems with ...

MS Paint command line switches

I have been looking for documentation related to interacting with MSPaint from the command line. I have only found references to /p, /pt and /wia, but no guidance as to how to use them and their limitations. I am trying to send some graphics files to the printer and when I drop the file on my printer driver I get a different print outpu...

Korn shell wraparound

Okay, I'm sure this is simple but it is driving me nuts. I recently went to work on a program where I've had to step back in time a bit and use Redhat 9. When I'm typing on the command line from a standard xterm running Korn shell, when I reach the end of the line the screen slides to the right (cutting off the left side of my command) i...

Command line builds for VC 6?

I have been used to working with VS2005 and 2008 - using msbuild, etc, but I have inherited a set of projects that have to remain in vc6.0 for now. I don't like opening each project in the developer studio and building. I prefer to build form command line (I am automating the builds). Is this possible? I have tried the nmake utility,...

How can I use xargs to copy files that have spaces and quotes in their names?

I'm trying to copy a bunch of files below a directory and a number of the files have spaces and single-quotes in their names. When I try to string together find and grep with xargs, I get the following error: find .|grep "FooBar"|xargs -I{} cp "{}" ~/foo/bar xargs: unterminated quote Any suggestions for a more robust usage of xargs? ...

How do I sort a file in place using bash shell?

I have a file temp.txt, that I want to sort with the "sort" command in bash. I want the sorted results to replace the original file. This doesn't work for example (I get an empty file): sortx temp.txt > temp.txt Can this be done in one line without resorting to copying to temporary files? EDIT: The -o option is very cool for sort. ...

Proxy for command line utilities in Win XP

How do I get command line utilities like ping to use the default proxy in Windows XP. proxycfg -u sets the proxy to the default (IE) proxy alright, but it doesn't seem to be working. Update: I am behind a proxy and would like a way to check if a site is up or not hence trying to use ping! Also would like a way to telnet (without using ...

Call a Mathematica program from the command line, with command-line args, stdin, stdout, and stderr.

If you have Mathematica code in foo.m, Mathematica can be invoked with -noprompt and with -initfile foo.m (or -run "<<foo.m") and the command line arguments are available in $CommandLine (with extra junk in there) but is there a way to just have some mathematica code like #!/usr/bin/env MathKernel x = 2+2; Print[x]; Print["There were ",...

How to use sed to replace only the first occurrence in a file?

I want to update a large number of C++ source files with an extra include directive before any existing #includes. For this sort of task I normally use a small bash script with sed to re-write the file. How do I get sed to replace just the first occurrence of a string in a file rather than replacing the every occurrence? If I use se...

SQL 2005 Express Edition - Install new instance

Looking for a way to programatically, or otherwise, add a new instance of SQL 2005 Express Edition to a system that already has an instance installed. Traditionally, you run Micrsoft's installer like I am in the command line below and it does the trick. Executing the command in my installer is not the issue, it's more a matter of dragg...

How can I test if a list of files exist?

I have a file that lists filenames, each on it's own line, and I want to test if each exists in a particular directory. For example, some sample lines of the file might be mshta.dll foobar.dll somethingelse.dll The directory I'm interested in is X:\Windows\System32\, so I want to see if the following files exist: X:\Windows\System32\...