title: Command line arguments with spaces to a C program through shell-wrapper script
body: <p>what does it take to make my program accept command-line arguments with spaces? </p>
  
  <p><strong>Yet-another EDIT</strong>: I have just recognized that the program is started from a shell-script that sets up the environment for the execution of the program. As there are some external libraries, <code>LD_LIBRARY_PATH</code> is set to the current working directory:</p>
  
  <pre><code>#!/bin/sh
  
  ARCH=`uname -m`
  export LD_LIBRARY_PATH=".:lib/magic/linux-${ARCH}"
  
  ./data_sniffer.bin $*
  
  exit $?
  </code></pre>
  
  <p>The issue is definitely related to <code>$*</code>. Is there any solution to correctly forward the command-line parameters?</p>
  
  <p>Here is a code-snippet from <code>main()</code>:</p>
  
  <pre><code>if (stat(argv[1], &amp;lStat) != 0)
  {   
      fprintf(stderr, "Cannot stat(2) given file: %s. \n", argv[1]);
      return EXIT_FAILURE;
  }   
  </code></pre>
  
  <p>I am starting my program with the following parameters:</p>
  
  <pre><code>./data_sniffer /mnt/pod/movies/some\ test\ movie\ file.avi
  </code></pre>
  
  <p>The resulting error message looks like this:
      Cannot stat(2) given file: /mnt/pod/movies/some.</p>
  
  <p>Anyone an idea what's wrong here? I think that I am not the first one with this problem (though, I could not find a related question here). </p>