shell

total size of group of files selected with 'find'

For instance, I have a large filesystem that is filling up faster than I expected. So I look for what's being added: find /rapidly_shrinking_drive/ -type f -mtime -1 -ls | less And I find, well, lots of stuff. Thousands of files of six-seven types. I can single out a type and count them: find /rapidly_shrinking_drive/ -name "*offende...

VB.NET shell command throwing a file not found exception!

I am trying to convert one of my unix text files to a dos text file. I am using the following command: Shell(string.format("unix2dos {0}", sFileCompletePath)) I've already added the unix2dos command in my environment path on the server. But when I execute the above mentioned command I get a FileNotFound exception even when the file i...

Access attributes from XML in shell

I'm trying to parse out values from a Widget config.xml using shell. I do want to use sed for this task. If there is something that sucks less than xsltproc, I'd love to know. In this example I am after the id attribute value from the config.xml below: <?xml version="1.0" encoding="UTF-8"?> <widget xmlns="http://www.w3.org/ns/widgets"...

Java Code formatting using shell script

I know this is silly but I can't overcome my curiosity. Is it possible to write a shell script to format a piece of java code? For example, if a user writes in a code: public class Super{ public static void main(String[] args){ System.out.println("Hello world"); int a=0; if(a==100) { System.out.println("Hel...

How can I run my application in place of the default Windows XP shell?

I was having a discussion with a colleague about whether or not the following is possible: Install an MFC application from a USB drive in Windows XP (this installation would be initiated manually by a user with sufficient privileges to install software). After rebooting, this application should start instead of the default Windows XP s...

How To Deploy Your PHP Applications Correctly?

Hi All, How to correctly deploy applications from development to production and how to deal with multiple site configurations. All my development are done thru svn located at var/svn/myapp/trunk and the actual production code is in /var/www/myapp. I check out the latest code to my local machine into a directory called "myapp_latest_sv...

In a bash script/command how can I make a PC beep noise, or play a sound file?

I have some long running scripts with breaks requiring input/interaction to continue but when I switch to another window I'd like to be notified (by sound) that a task is complete and now awaiting input. I would prefer to be able to play an audio clip (*.mp3, *.ogg, etc.) but wouldn't care if the only solution is to make the PC Speaker ...

Case-Insensitive ZSH Suffix Aliases

In my .zshrc I've set up suffix completion aliases like this so that I can open files more easily: alias -s -- txt='mate -w' Which allows me to open text files in my text editor without prepending the editor command. There is a problem, however, when I am attempting to open a file with a capitalized suffix. ZSH will recognize '.txt' ...

How can I translate a shell script to Perl?

I have a shell script, pretty big one. Now my boss says I must rewrite it in Perl. Is there any way to write a Perl script and use the existing shell code as is in my Perl script. Something similar to Inline::C. Is there something like Inline::Shell? I had a look at inline module, but it supports only languages. ...

Continuously read from STDOUT of external process in Ruby

I want to run blender from the command line through a ruby script, which will then process the output given by blender line by line to update a progress bar in a GUI. It's not really important that blender is the external process whose stdout I need to read. I can't seem to be able to catch the progress messages blender normally prints ...

(Windows) Permanently altering a user's %PATH% via batch or Python

I'm packaging a Python project with setuptools and distributing it with easy_install, which allows me to place an executable file in a Scripts directory, hidden away inside the Python directory. For Linux users who run easy_install as root, there will be added a symbolic link in a standard bin directory (/usr/bin/, iirc). For Windows u...

Shell script to log server checks runs manually, but not from cron

I'm using a basic shell script to log the results of top, netstat, ps and free every minute. This is the script: /scripts/logtop: TERM=vt100 export TERM time=$(date) min=${time:14:2} top -b -n 1 > /var/log/systemCheckLogs/$min netstat -an >> /var/log/systemCheckLogs/$min ps aux >> /var/log/systemCheckLogs/$min free >> /var/log/syste...

Running sh script through AuthorizationExecuteWithPrivileges

Hi, I'm running an uninstallation script through cocoa app, and I noticed that launchctl command doesn't get executed. This is the part of the code that calls script (which contains sudo launchctl unload "name of the daemon") //pFileName is the name of the File NSString* pPath = [pCurrentBundle pathForResource:pFileName ofType:@"sh"]...

How can i use the wifi device connected through bash scripting?

How can i figure out if I have wifi devices connected to my PC thru bash scripting? * Is there anyway aside from 'iwconfig'? * If i have two devices connected and am using device A. Now if device A is down, then how can i setup to use device B instead? I'm just learning bash scripting, tutorials kinda confused me with all the new "co...

How i can do a shell script to know if my connection is up on ubuntu

I'm very low with shell scripts.. I need to check with a cron (no problem for this) if my connection is up. If it isn't, i want to call some scripts to reconnect. I was thinking about using grep and ping to some site (or ip), then check the returned string. Then call my command: sudo pppd call speedtch I need a clue thanks! Or ther...

How to pass long strings for search and replace in a bash, sed, or rpl script?

I am working to create a script which will take a string as an argument and replace recursively in a directory. The simple case (a single word) is admirably handled by the following find and replace script: grep -rl $1 . | xargs sed -i .backup -e "s/$1/$2/g" But here things get a bit more tricky. The string I am trying to deal with...

How to custom display prompt in KSH to show hostname and current directory?

I'm using Korn Shell on Solaris and currently my PS1 env var is: PS1="${HOSTNAME}:\${PWD} \$ " And the prompt displays: hostname:/full/path/to/current/directory $ However, I'd like it to display: hostname:directory $ In other words, how can I display just the hostname and the name of the current directory, i.e. tmp or ~ or public_h...

shell script to link specific files up one level

I've got a folder that's got a whole lot of folders inside, which each contain a movie file. Now I want to be able to see all these movies at one time (but I have to preserve the folder structure) so I wanted to symlink them all to the top level folder (flat view in Directory Opus would be the go here, but I'm on a mac). Here's my attemp...

OS X terminal command to resolve path of an alias

I'm writing a shell script which will rsync files from remote machines, some linux, some macs, to a central backup server. The macs have folders on the root level containing aliases of all files/folders which need to be backed up. What is a terminal command I can use to resolve the path to the files/folders the aliases point to? (I'll ne...

WPF Shell Drag Drop Sample - Unsafe Code

I have been considering using the code example shown at Shell Style Drag and Drop in .NET - Part 3 within a WPF project. The sample project works fine, it is a great article so check it out! However when moving the code to my project I receive an error when compiling "Unsafe code may only appear if compiling with /unsafe" I understa...