Skip to main content

Posts

Showing posts with the label Shell Commands

Running PowerShell commands from Linux

There are several options for running PowerShell commands from Linux. Run the PowerShell script over a REST interface Unless you need a remote shell, the easiest option is to set up a REST interface for your PowerShell scripts. More information here . Using the winrm Ruby Gem https://github.com/WinRb/WinRM Using a WS-Management client on Linux Set up Windows for remote access: https://github.com/Openwsman/openwsman/wiki/winrm-over-openwsman-setup Install OpenWSMAN on Linux: http://openwsman.github.io/ Use Openwsman Command-Line Client: https://github.com/Openwsman/openwsman/wiki/openwsman-command-line-client OR - Use Ruby client bindings: http://users.suse.com/~kkaempf/openwsman/ Install an SSH server on Windows Install a Salt Minion on Windows Install Salt Master on Linux Install Python on Windows Install Salt Minion on Windows Open firewall on Windows for Salt access On Linux, run: # salt "winServer" cmd.run "powersh...

Cmd.exe - Using For Loops To Simulate "grep -r */Filename" on Windows

FOR %variable IN (set) DO command [command-parameters] %variable Specifies a single letter replaceable parameter. (set) Specifies a set of one or more files. Wildcards may be used. command Specifies the command to carry out for each file. command-parameters Specifies parameters or switches for the specified command. To perform a grep operation on all files with a certain name in subdirectories of the current directory, although this will try to grep Folder\Filename.ext even if Filename.ext doesn't exist in the folder. for /d %I in (*.*) do grep grepString %~sI\Filename.ext This is slower, but it won't pass files that don't exist to grep, and will recursively search all subdirectories under the current directory. The first example only goes one level deep. for /f "usebackq delims=;" %I in (`dir /s/b Filename.ext`) do grep grepString "%I" The "delims=;" (you can use almost anything for the ;) is required if there are spaces in t...

Google dictionary for Bash

For Bash, use Google to get word definitions on the command line by putting this in your .bashrc file: def () { lynx -cfg=/dev/null -dump "http://www.google.com/search?q=define%3A$*" | less; } (Make sure that is all on one line) Then type "def word" to get a definition for "word". You can also create a shell script like so: #!/bin/csh -f lynx -cfg=/dev/null -dump "http://www.google.com/search?q=define%3A${1}" | less This will work if you aren't using Bash. Make the script executable and put it in your search path (~/bin is a good place). You need a copy of lynx (or better yet links ) for this to work. The "-cfg=/dev/null" is optional for lynx, but should be removed if you are using links.