shell

PowerShell search script that ignores binary files

I am really used to doing grep -iIr on the Unix shell but I haven't been able to get a PowerShell equivalent yet. Basically, the above command searches the target folders recursively and ignores binary files because of the "-I" option. This option is also equivalent to the --binary-files=without-match option, which says "treat binary f...

windows shell, move multiple file arguments error

f:\i>move foo bar dir The syntax of the command is incorrect help move says: MOVE [/Y | /-Y] [drive:][path]filename1[,...] destination This seems to imply multiple arguments. So how can I give multiple arguments to move? ...

ShellScript: Whats the diff between % and %% here?

Hi, I am a shell script newbie. I want to know the difference between ${var%pattern} and ${var%%pattern} Thanks ...

Powershell Script fails after accessing Array.Length Property

Can someone explain why this script throws an exception? $byteArray = @(1,2,3) write-Output ( "{0:X}{1:X}{2:X}" -f $byteArray ) write-Output ( $byteArray.Length -ge 3 ) write-Output ( "{0:X}{1:X}{2:X}" -f $byteArray ) Basically, I am creating an array of numbers, formatting the array and then checking its length and formatting it agai...

Write a shell script that find-greps and outputs filename and content in 1 line

To see all the php files that contain "abc" I can use this simple script: find . -name "*php" -exec grep -l abc {} \; I can omit the -l and i get extracted some part of the content instead of the filenames as results: find . -name "*php" -exec grep abc {} \; What I would like now is a version that does both at the same time, but on...

CoCreateInstance fails with 0x80040154 on ITaskBarList3...

Does anyone have any idea why CoCreateInstance would be failing on ITaskBarList3 on Windows 7 64-bit? The error code is 0x80040154, which is Class Not Registered. The calling code (VB6) is: Public Const IID_ITaskbarList3 = "{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}" Public Const CLSID_TaskbarList3 = "{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}...

Is there a way to replace the "openwith" name for java apps in windows?

i have a java app in windows, put in the registy the entries for the file extension and for the app. HKEY_CLASSES_ROOT/.xxx -> (Default)=xxxApp, Content Type=..., PerceivedType=... HKEY_CLASSES_ROOT/.xxx/OpenWithProgIDs -> (Default)=xxxApp HKEY_CLASSES_ROOT/.xxx/ShellNew -> command=c:\java... -jar xxxApp.jar and ItemName=xxxApp HKE...

How to use the php command line interactively?

Are there any howtos for using the php command line interactively? I found a lot about running sripts that are in text-files, but not really about the shell with the prompt where I type in commands: $ php -a Interactive shell php > echo "hello world"; hello world php > $a = 1; php > echo $a; 1 php > exit; $ When I go to the linux she...

Execute xp_cmdshell command as specific user

Hello, I would like to run xp_cmdshell (TSQL procedure) in order to mount a network drive and then access remotes mdb files. I am administrator on the MS SQL server and I have allowed xp_cmdshell execution accordingly. However, there is still a problem: When I call xp_cmdshell, the user executing the command is the SQL SysAdmin, i.e...

What is the correct way to "pipe" Maven's output in Python to the screen when used in a Python shell script?

My Python utility script contains UNIX system calls such as status, output = commands.getstatusoutput("ls -ltr") print "Output: ", output print "Status: ", status Which work fine and print the output to the console but as soon as I run Maven from the same script, status, output = commands.getstatusoutput("mvn clean install -s./../.....

Bash command (netstat etc) to show overview of packet transfer?

Let's say I have a Linux machine that is being bogged down by some network traffic. Might be someone FTPing a large file to it, a bunch of people downloading a large file, etc. What are some options I could use to determine this? I've looked over say the netstat man but I'm not sure if this would be exactly what I need. It could at leas...

Set TShellListView Persistent Column Widths in Code

Is there any way to persistently set the column widths on a Delphi 2007 TShellListView in vsReport mode using code? The normal ShellListView.Columns[0].Width property only sets the width for the current directory, and that width is reset after every change of the current directory or refresh of the file list (including refreshes and dir...

Executing The Same Command In Multiple Shell Scripts

I'm using the following to to tee output of a command into a file: logs/`basename $0`-`basename $1`.`date +%F--%R\`.log And since this same syntax belongs in several different shell scripts, I'd really like it to only appear once. My first thought was to put it in another shell script: export LOGFILE=logs/`basename $0`-`basename $1`...

Building grep strings dynamically

I am writing a shell script to do a "tail" on a growing log file. This script accepts parameters to search for, and incrementally greps the output on them. For example, if the script is invoked as follows: logs.sh string1 string2 it should translate to: tail -f logs.txt | grep string1 | grep string2 I am building the list of grep ...

Improving Shell Script Performance

This shell script is used to extract a line of data from $2 if it contains the pattern $line. $line is constructed using the regular expression [A-Z0-9.-]+@[A-Z0-9.-]+ (a simple email match), form the lines in file $1. #! /bin/sh clear for line in `cat "$1" | grep -i -o -E "[A-Z0-9.-]+@[A-Z0-9.-]+"` do echo `cat "$2" | grep -m 1 ...

contents of ouput file of "script" command is cryptic

When i run script to log the entire console , the output file is crytpic with symbols like ^[d ^M ^[ ^@ ^@ etc.. Is there a editor which will remove and open the file that looks like exact console logs ..... ...

Vista Shellview Help button

Hi I have created a namespace extension with VC 2005... I was wondering how to utilize the Help button located on the vista toolbar to display the help document for my product. Currently the help button is available but clicking it does not do anything. I was wondering how to handle the help button in Vista and 7 as this is a new feat...

What happens when I execute a unix shell script using a '.' command?

For e.g., when I say ". .bashrc" on my linux command prompt, is there a corresponding binary/script that gets executed in place of the first dot? If the dot itself is a command, where is its location? ...

recursively add file extension to all files

I have a few directories and sub-directories containing files with no file extension. I want to add .jpg to all the files contained within these directories. I've seen bash scripts for changing the file extension but not for just adding one. It also needs to be recursive, can someone help please? ...

terminal color in ruby?

hi is there a ruby modul for colorize strings in a linux terminal? ...