# Trouble passing arguments to other programs

This topic is 4518 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Organising a huge number of images is tiresome, and especially searching for duplicate images with different names. To alleviate this burden I decided to write a little utility that'd help me find images with identical sizes and SHA-1 hashes. Everything works great, except interaction with other applications. When the user passes "-q" to the application, output is supposed to be limited to only the filenames of possible duplicate files, discarding other diagnostic info. The purpose of this is to make it easier to use the utility with other applications. One might first run the application in its normal mode of operation, to find out if there are any possible dupes. If there are any, we might want to take some action. For example, opening all the suspects in Firefox, to confirm that they are indeed the same. This is where I run into trouble.
$./dupsearch -q Mai.Otome.HiME-Yuripack 'Mai.Otome.HiME-Yuripack/Mai Hime - 079.gif' 'Mai.Otome.HiME-Yuripack/fanart_08_15.gif' 'Mai.Otome.HiME-Yuripack/Mai Hime - 013.jpg' 'Mai.Otome.HiME-Yuripack/mr_cg160.jpg'  As you can see, the application outputs all of the filenames in single quotes. If we copy this and paste it into the terminal, it works just fine: $ mozilla-firefox 'Mai.Otome.HiME-Yuripack/Mai Hime - 079.gif' 'Mai.Otome.HiME-Yuripack/fanart_08_15.gif' 'Mai.Otome.HiME-Yuripack/Mai Hime - 013.jpg' 'Mai.Otome.HiME-Yuripack/mr_cg160.jpg'

However, this is a real bother, especially when there are lots of duplicate images. Therefore I'd do something like this:
$mozilla-firefox ./dupsearch -q Mai.Otome.HiME-Yuripack  This works fine - as long as none of the file or directory names contain any spaces. When there are spaces, it seems that the shell decides that each space denotes a new parameter, even when the space is part of a quoted word. This is a bit weird, seeing as it works fine with the same data if you copy and paste it. Does anyone have any suggestions about what I could do to fix this? I'm using bash on a Debian Unstable system. #### Share this post ##### Link to post ##### Share on other sites Advertisement try using double quotes like this:$ mozilla-firefox ./dupsearch -q "image name with spaces.jpg"

or if it doesnt work try:

Quote:
 Original post by Will FSee if it works using a pipe$./dupsearch -q Mai.Otome.HiME-Yuripack | mozilla-firefox Didn't work either. Firefox and most other utilities I'd consider using it with wants the files as arguments, not piped to stdin. #### Share this post ##### Link to post ##### Share on other sites Have you tried using xargs? It allows passing arguments to a program in lots of weird and wonderful ways. You can check out how by the usual "man xargs", it should help you solve your problem. #### Share this post ##### Link to post ##### Share on other sites Quote:  Original post by ValdermanDidn't work either.Firefox and most other utilities I'd consider using it with wants the files as arguments, not piped to stdin. Didn't think it would. I don't see any reason why the way you do it should fail, considering that it works if you copy/paste the output. The only thing I can think of is to escape the spaces in the filenames rather than quoting the file. For example, Mai.Otome.HiME-Yuripack/Mai Hime\ -\ 079.gif is equivalent to 'Mai.Otome.HiME-Yuripack/Mai Hime - 079.gif' but I doubt that'll make any difference. #### Share this post ##### Link to post ##### Share on other sites I think i've found a possible cause of problem - using ./ between   behaves differently than you are expecting it to. Then again, it's just a guess I don't know enough about the behavior of   to competently say that this is the problem. I wrote a hello world script in perl - take a look at the command line output from 2 attempts to invoke it $ ./helloworldhelloworld$./helloworld -bash: helloworld: command not found I don't have access to a linux box right now, the above was tested on OS X - but I assume bash would behave the same on both. In your case try adding the directory dupsearch resides in to your path and run it like this $ mozilla-firefox dupsearch -q Mai.Otome.HiME-Yuripack

[Edited by - Will F on March 5, 2006 9:17:28 PM]

##### Share on other sites
Hmm I made a similar test and I could use the ./
However, Im using firefox stable, and the only command line that works is

$mozilla-firefox "myimage.gif"$ mozilla-firefox "myimage.gif" "myimage2.gif"
gives me the usage message... (same without the quotes)

1. 1
Rutin
26
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 10
• 9
• 9
• 46
• 41
• ### Forum Statistics

• Total Topics
631751
• Total Posts
3002076
×