bash script ? -- spaces in passed parameters
Hi, I'm fairly new to Linux, and trying to do some rudimentary bash scripting. Here's my problem, I'm writing a really simple bash script to run the mp3 encoder Lame with my normal command-line arguments (more as an experiment than a real necessity), and am having problems with I'm passing it command-line parameters with spaces involved. For instance, this command executed in a shell works just fine, where hde1 is my other hd still in Fat32 with windows installed as a dual-boot (barely used now),
lame --preset standard "/mnt/hde1/windows/desktop/from other hd/to encode.wav" but this simple bash script does not work, when I execute it as ./lamescript "/mnt/hde1/windows/desktop/from other hd/to encode.wav" Code:
#!/bin/bash What confuses me though, is that if I echo the same command, everything looks to be formated exactly as it is when I type it directly into the shell, which works. Any ideas?? ~Andrew |
change \"$1\" to just $1
and if the path contains spaces try using a backslash before the space, instead of double quotes eg. /mnt/hde1/windows/desktop/from\ other\ hd/to\ encode.wav |
Thanks for the quick response, but so far neither worked. If it makes any difference, I have a similar problem with the wine in my KDE menu ... it has the command "wine %f" and if the filename or directory has spaces in it, it won't work using the "open with..." from knqueror, but it works fine directly in the bash shell.
|
Well, just thought I'd update my own thread in case anyone else has any similar problems ... I believe I've narrowed it down to being an error in the way this build of Lame parses the command-line arguments (although I'm still confused as to why it would work from a shell but not from a script).
I say this because I've made some scripts to execute other programs with arguments with spaces in the path, and it works just fine. For example, Code:
#!/bin/bash Guess I'll let this one go until I run across some good reason why one works and not the other, ~Andrew |
All times are GMT -5. The time now is 03:36 PM. |