PDA

View Full Version : sh/perl/python help/request



vexorian
July 28th, 2007, 12:05 AM
Hello, I need some help with an script I'd like to make. I want something that would take an argument, the argument is a file path, but then it should convert it to a MSDOS path for wine...

For example

/home/name/alg tur/k.w3x

becomes:

"Z:\home\name\alg tur\k.w3x"

And I then have to concatenate that (including the quotes) to a call to a WINE program.

Please help before the mad side of my brain forces me to compile a C++ program for this...

Mr. C.
July 28th, 2007, 05:55 AM
A simple sed command might work for you:


#!/bin/bash

echo "$1" | sed -e 's-^-Z:-' -e 's-/-\\-g'

MrC

jyba
July 28th, 2007, 06:13 AM
Or use substring replacement...

#!/bin/bash

echo "\"Z:${1////\\}\""

slavik
July 28th, 2007, 02:30 PM
might as well do in perl:



#!/usr/bin/perl
print "Z:" . join '\\', split /\//, @ARGV[0] . "\n";

vexorian
July 28th, 2007, 03:10 PM
thanks