windows console: spawn new process

posted by alexis reigel on january 19, 2011

Under linux spawning a new process is as easy as appending an & to the command. In windows it’s not (obviously). I pretty quickly found out about the start command. Not as elegant as the linux version, but still pretty intuitive. Or, wait, not? It took me half a decade to find out how to use it properly.

First i had a look at the help output, which can be invoked by the switch /?. I’m not 100% sure, but i have in mind that this switch isn’t really standardized, i think I also had to use /h or /help in the past. Anyway, that’s not the sad part yet.

console start

Reading through that, all you have to do is call start my_command. Easy huh? No. It’s not.

After digging around this article lead me to the solution: “title: Text for the CMD window title bar (required)”. Title! Required!
Let me say that again. Title! Required!
First thought: Why? Why is a title required? A title is clearly something optional, especially when you’re starting a GUI application.
Second thought: Why? Why is that “required” not stated as such in the help output? Not the slightest hint in the help output. And furthermore, isn’t it a convention that required parameters are NOT surrounded by brackets? Don’t brackets mean “optional”? Apparently, in the windows tooling environment all this does not apply.

I know, windows is a GUI centered OS, and therefore the console didn’t evolve as nicely as it did in other OS’s. Nevertheless, every time I have to work on a console or write a batch file it gives me the creeps. Everything is so unbelievably clumsy. At least I found out about the Console project, which is a pretty decent replacement for the windows console. Copy/paste works as desired with keyboard shortcuts and you can resize the window. Resize the window! How cool is that! But that’s a different story…

useful linux commands

posted by alexis reigel on january 16, 2004

This is a random aggregation of useful linux commands.
Useful for those who will be eventually stuck as I once was.
Or those who didn’t know that certain things can be done in such a smooth way…

Print a locked pdf

To be able to print a pdf file even though it has been print locked you can convert the pdf to postscrloipt and back again to a pdf.

$ pdf2ps locked.pdf && ps2pdf unlocked.pdf

Mount a cd-rom image

This will mount an image file to a certain mountpoint such that it can be used as a usual drive (like a virtual drive in windows).

$ mount -o loop -t iso9660 <isofilename> <mountpoint>

ssh with x-window support

With this you can launch an x-window application via an ssh connection (provided that the host computer does support the particular toolkit).

$ ssh -l <loginname> <remote-host> -X -C <path-to-application>

Print out manpage

Prints out a manpage in a nicely formatted way.

$ man <manpage> | col -b | ul -t dumb | lpr -P<printername>

$ man -Tps <manpage> | lpr -P<printername>

Find advanced

Find is a very powerful command, as it is extensible in a very convenient way.
Every find-result is passed to “command”.

$ find <parameters> -exec <command '{}' ';'>

example 1, copies all jpg images to the folder “img/”

$ find -name *.jpg -exec cp '{}' img/ ';'

example 2, searches all textfiles for “searchstring”

$ find -name *.txt -exec grep "searchstring" '{}' ';'

Disable beep

If it’s about time to disable the annoying beep in the shell. For the current user

$ echo "set bell-style none">> ~/.inputrc

For all users (you have to be root) in /etc/inputrc set the line set bell-style none

Convert a text file from DOS to Unix style

This tool converts dos formatted text files with end-of-line ^M^J to unix end-of-line ^J.

$ dos2unix <file>

Patch file

With the following command you create a patch file from any source file.

$ diff -u src.old src.new1 > file.patch0

To apply the patch

$ patch -p0 file < file.patch0

Convert a large file into small files

$ split -b 650m file # split file into 650MB chunks

$ cat x* > largefile # merge files into 1 large file

Web page dump

The following will save the contents of a web page to a textfile.

$ lynx -dump > textfile

Clear file contents

In order to clear the contents of a file such as a logfile, do not use rm to delete the file and then create a new empty file, because the file may still be accessed in the interval between commands. The following is the safe way to clear the contents of the file.

$ :>file-to-be-cleared

Merge two PostScript or PDF files

$ gs -q -dNOPAUSE -dBATCH -sDEVICE=pswrite -f

$ gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=merge.pdf -f file1.pdf file2.pdf

Samba client basics

Mount a windows (samba) share

$ mount -t smbfs -o username=myname,uid=my_uid,gid=my_gid //server/share /mnt/smb

$ smbmount //server/share /mnt/smb -o "username=myname,uid=my_uid,gid=my_gid"

List the shares on a computer

$ smbclient -L

Samba neighbors can be checked from Linux using the following command

$ smbclient -N -L ip_address_of_your_PC | less

$ nmblookup -T "*"

Make iso from cd

$ dd if=/dev/cdrom of=image.iso

Burn iso to cd

For an ide device

$ cdrecord -v speed=SPEED dev=ATAPI:1,0,0 -data image.iso

To find out the device number, use the following command

$ cdrecord -scanbus dev=ATAPI

Alternatively, you can specify the ide device directly

$ cdrecord -v speed=SPEED dev=ATAPI:/dev/hdc -data image.iso

For a scsi device

$ cdrecord -v speed=SPEED dev=1,0,0 -data image.iso

To find out the device number, use the following command

$ cdrecord -scanbus