shell

Python's os.execvp equivalent for PHP

I've got a PHP command line program running. And I want to connect to a mysql shell straight from PHP. I've done this before in Python using os.execvp But I can't get the same thing to work in PHP. I've tried the following functions: system passthru exec shell_exec example: system('mysql -u root -pxxxx db_name'); But they all see...

Using wget to recursively fetch a directory with arbitrary files in it

I have a web directory where I store some config files. I'd like to use wget to pull those files down and maintain their current structure. For instance, the remote directory looks like: http://mysite.com/configs/.vim/ .vim holds multiple files and directories. I want to replicate that on the client using wget. Can't seem to find the ...

How do I manipulate $PATH elements in shell scripts?

Is there a idiomatic way of removing elements from PATH-like shell variables? That is I want to take PATH=/home/joe/bin:/usr/local/bin:/usr/bin:/bin:/path/to/app/bin:. and remove or replace the /path/to/app/bin without clobbering the rest of the variable. Extra points for allowing me put new elements in arbitrary positions. The targe...

Can't do shell script with a repeat with i from 1 to n loop

This works (prints, for example, “3 arguments”): to run argv do shell script "echo " & (count argv) & " arguments" end run This doesn't (prints only “Argument 3: three”, and not the previous two arguments): to run argv do shell script "echo " & (count argv) & " arguments" repeat with i from 1 to (count argv) do shell script "ec...

How to send ^K to shell

I want to run a shell command in Terminal, then clear the console, from Applescript. If I was doing this by hand, I'd use ^K -- how do I send the ^K character in a string to Terminal? ...

Is there a good Python GUI shell?

I saw this the other day (scroll all the way down to see some of the clever stuff): http://www.mono-project.com/CsharpRepl And wondered whether something like this exists for Python. So, is there a good Python GUI shell that can do stuff like that C# shell can do? Edit: Here are links to screenshots from the article, showing wha...

Using capistrano when remote git is on a non-standard path

My shared host did not provide git, so I built and installed it into ~/bin. When I ran it, I got the following error on most commands, although they were successful. stdin: is not a tty I can solve that problem by adding: default_run_options[:pty] = true to my deploy.rb, but then I get this error, which blocks deployment:...

Where does '.' and '..' come from?

What's the story behind our massive repitition of './foo' and 'cd ..'. Where do these two '.' and '..' come from? Where could they be seen as a way of navigating a file system tree for the first time? I seem to have formulated this question a bit vague. Answers to earliest reference have been found, however, the question remains to why ...

how do you normalize a file path in bash?

I want to transform "/foo/bar/.." to "/foo" Is there a bash command which does this? ...

Running a Windows Batch Script to Startup Multiple Files

I'm trying to replace the programs that run from my startup directory with a batch script. The batch script will simply warn me that the programs are going to run and I can either continue running the script or stop it. Here's the script as I have written so far: @echo off echo You are about to run startup programs! pause ::load o...

How to safely escape a string from C++

I'm writing a simple program to browse the local network and pass on filenames to mplayer using "system". However, sometimes filenames contain spaces or quotes. Obviously I could write my own function to escape those, but I'm not sure exactly what characters do or do not need escaping. Is there a function available in the CRT or somewhe...

Bash Shell Scripting: what simple logic am I missing

This may be too generic a question as is but... I am stumped by trying to move through the directories from within a shell script. I'm not a *nix power user, but I am comfortable working through the command line for most tasks. I'd like to call a script that can move 'me' to a directory instead of just the script process similar to the f...

How do I add a directory with a colon to PYTHONPATH?

The problem is simple: Using bash, I want to add a directory to my PYTHONPATH for ease of script execution. Unfortunately, the directory I want to use has a : in it. So I try each of the following export PYTHONPATH=${PYTHONPATH}:/home/shane/mywebsite.com:3344/ export PYTHONPATH=${PYTHONPATH}:/home/shane/mywebsite.com\:3344/ export PYTH...

CommonAppData in vbscript

A customer's application "AppName" has its configuration files stored in CommonAppData. Under Windows XP that is C:\Documents and Settings\All Users\Application Data\AppName Under Windows Vista that is C:\ProgramData\AppName How do I get the correct foldername with VBScript? ...

Shortest command to calculate the sum of a column of output on Unix?

I'm sure there is a quick and easy way to calculate the sum of a column of values on Unix systems (using something like awk or xargs perhaps), but writing a shell script to parse the rows line by line is the only thing that comes to mind at the moment. For example, what's the simplest way to modify the command below to compute and displ...

How can I tell if a file is on a remote filesystem with Perl?

Is there a quick-and-dirty way to tell programmatically, in shell script or in Perl, whether a path is located on a remote filesystem (nfs or the like) or a local one? Or is the only way to do this to parse /etc/fstab and check the filesystem type? ...

`(cd X; pwd)` sometimes returns two-line

I have shell script which starts with: sdir=`dirname $0` sdir=`(cd "$sdir/"; pwd)` And this usually gets expanded (with 'sh -h') into ++ dirname /opt/foo/bin/bar + sdir=/opt/foo/bin ++ cd /opt/foo/bin/ ++ pwd + sdir=/opt/foo/bin but for single user for single combination of parameters in expands into (note two lines at the result ...

How do I display an icon in the System Tray?

I want to make my .Net application display a notification in the system tray. So I want to show an icon for that, can anyone tell how to do that? ...

javascript (spidermonkey) how does one run a linux command from js shell?

I'm stumped and feeling stupid. I've tried every search combination I can think of to figure this out. It seems simple, but being new to javascript I'm not seeing anything helpful in my search for examples or demos. I'm looking to use a script like I would a python or perl script to run a simple linux command. The interpreter is up and r...

Process.Start() throwing intermittent "No application is associated.." on .DOC files

System.Diagnostics.Process.Start() is throwing intermittent System.ComponentModel.Win32Exception: No application is associated with the specified file for this operation. The file is a .doc file. They are always able to open it manually (double-click). What could be the problem? Thanks ...