Linux how do i escape spaces in a filename? (scroll down)

Discussion in 'Tech Support' started by notatoad, 4 Mar 2009.

  1. notatoad

    notatoad pretty fing wonderful

    Joined:
    25 Jun 2004
    Posts:
    3,213
    Likes Received:
    60
    i finally got around to setting up rtorrent today on my fileserver, and i'm loving it. i've got it set right now so that the watched directory that i download .torrents to is mounted on my desktop machine as an nfs share, but i'm having some problems with permissions. if i drag a .torrent into the folder from the desktop, all is good. but if i tell firefox to handle .torrents with a script that moves them automatically to the watched folder, they end up with no owner and so rtorrent doesn't have permissions to open them. how can i set the torrents i copy in to be owned by me?

    relevant line of /etc/exports on fileserver
    Code:
    /home/kyle/downloads 192.168.0.0/16(rw)
    relevant line of /etc/fstab on local
    Code:
    filserver:/home/kyle/downloads    /home/kyle/downloads   nfs  user  0 0
    script that firefox handles .torrents with
    Code:
    #!/bin/bash
    mv $1 /home/kyle/downloads/.watched/
    
    any suggestions?

    edit: if i run the script from the commandline the permissions are still ok, so it has to be something to do with how firefox calls the script. or maybe it's that the .torrent that firefox downloads never gets an owner. :confused:
     
    Last edited: 6 Mar 2009
  2. C-Sniper

    C-Sniper Stop Trolling this space Ądmins!

    Joined:
    17 Jun 2007
    Posts:
    3,028
    Likes Received:
    126
    I think chown is the command you are looking for.


    Code:
    #!/bin/bash
    chown <username> $1
    mv $1 /home/kyle/downloads/.watched/
    I think this will work but if not, just post back and I'll try to think of something else ;)
     
  3. notatoad

    notatoad pretty fing wonderful

    Joined:
    25 Jun 2004
    Posts:
    3,213
    Likes Received:
    60
    no, that didn't work.
    Code:
    chown kyle $1 2> ~/torrentmover.log
    should output stderr to a file right? because even though it didn't work, torrentmover.log is empty.
     
  4. Glider

    Glider /dev/null

    Joined:
    2 Aug 2005
    Posts:
    4,173
    Likes Received:
    21
    chown only works as root... That's why it probably didn't work. Also, I don't think it returns anything.

    A couple of questions:
    What does
    Code:
    ls -al /home/kyle/downloads
    on both system return?
    When Firefox is running, what does
    Code:
    ps aux| grep firefox
    return?

    You can try to set the .torrent directory so that it's group readable and add rtorrent (user) to the group kyle is in?
     
  5. trigger

    trigger Procrastinator

    Joined:
    22 Mar 2004
    Posts:
    1,097
    Likes Received:
    30
    My guess would be the file isn't actually written by firefox to your desktop, it only ever writes it to the server so when you do the mv it hasn't got any permissions yet. Have you tried the chown command after the mv? That way you are definitely chown-ing the file that has been written.

    You may need to chmod it as well, I guess 755 should do the trick.
     
  6. notatoad

    notatoad pretty fing wonderful

    Joined:
    25 Jun 2004
    Posts:
    3,213
    Likes Received:
    60
    ls -al /home/kyle/downloads on fileserver gives (block and date omitted)
    Code:
    drwxrwxrwx  2 kyle kyle      .
    drwxrwxrwx 16 kyle kyle      ..
    -rw-r--r--  1 nobody nobody  all.torrents
    desktop is the same thing but nobody nobody is replaced with nouser nogroup. (different versions of ls?)

    ps aux
    Code:
    kyle 11864 1.9 5.4 652496 ? Sl 01:27 11:43 /usr/lib/firefox-3.0.6/firefox
    trigger, as glider says chown won't work because it's not root.
     
    Last edited: 4 Mar 2009
  7. notatoad

    notatoad pretty fing wonderful

    Joined:
    25 Jun 2004
    Posts:
    3,213
    Likes Received:
    60
    gah, i had all_squash option set on the nfs server. :duh: fixed now. thanks for the help guys.
     
  8. notatoad

    notatoad pretty fing wonderful

    Joined:
    25 Jun 2004
    Posts:
    3,213
    Likes Received:
    60
    okay, new problem. when i try to add a torrent with spaces in the filename, mv takes the spaces to mean they're separating arguments. is there an easy way to replace every ' ' in $1 with '\ '?
     
  9. Millusdk

    Millusdk What's a Dremel?

    Joined:
    27 Jan 2008
    Posts:
    140
    Likes Received:
    1
    I don't know if this will work, but can't you place the filename inside ""?
    So it looks something like this:
    mv "path/to/file name" "path/to/file name"
     
    notatoad likes this.
  10. Boldar

    Boldar Minimodder

    Joined:
    24 Feb 2003
    Posts:
    284
    Likes Received:
    4
    What he said ^^^
     
    notatoad likes this.
  11. Glider

    Glider /dev/null

    Joined:
    2 Aug 2005
    Posts:
    4,173
    Likes Received:
    21
    I concur :D
     
    notatoad likes this.
  12. notatoad

    notatoad pretty fing wonderful

    Joined:
    25 Jun 2004
    Posts:
    3,213
    Likes Received:
    60
    thanks.
     
Tags:

Share This Page