title: Can't execute ls using shell script
body: <p>I'm trying to parse vsftpd logs to do some extra processing on the successfully uploaded files.</p>
  
  <p><code>username</code> will be the user so I create the home dir
  <code>filename</code> is the file name in the log: it gives a wonky result i.e. "/foo.txt" but that doesn't matter</p>
  
  <pre><code>#!/bin/sh
  sudo tail -F /var/log/vsftpd.log | while read line; do
    if sudo echo "$line" | grep -q 'OK UPLOAD:'; then
      username=$(echo "$line" | cut -d" " -f8 | sed 's/\[\(.*\)\]/\1/')
      filename=$(echo "$line" | cut -d, -f2 | sed 's/^[ \t]*//')
      home="/home/vsftpd/$username"
      if sudo ls "$home$filename" &amp;&gt; /dev/null; then
        # do something with $filename
          echo "some text"
      fi
    fi
  done
  </code></pre>
  
  <p>When a file is uploaded I expect the text "some text". I never get that instead I can see it reports: </p>
  
  <p><code>ls: cannot access /home/vsftpd/user1"/foo.txt": No such file or directory</code></p>
  
  <p>Although I can run the command in the shell:</p>
  
  <pre><code>$ sudo ls /home/vsftpd/user1"/foo.txt"
  /home/vsftpd/user1/foo.txt
  </code></pre>
  
  <p>I'm guessing permissions related but I've got it running as sudo and I've given the directories full access. Any ideas?</p>