Mount expression not working in nautilus script
I'm sure this is something really stupid but I'm really tired and I'm kind of burned out on ideas, at this point.
Here is a segment from a script (the script is complicated so I'll just post the problem) Code:
echo "sudo mount -o loop $eFile $eMount" > syntax.txt The first line returns: Code:
sudo mount -o loop /home/abigail.dunning/Training/1994-2010\ Linux\ Journal\ Master\ Collection.iso /media/iso/1994-2010\ Linux\ Journal\ Master\ Collection However, this is being run in a nautilus script and the output of the same mount command is the syntax for mount??? Code:
# contents of error.log |
Hi,
Only thing I see is a missing fstype option. Maybe when you do this from a bash shell it is guessed correctly and not so when done from a nautilus script (which I'm not familiar with). Try changing it to: Code:
echo "sudo mount -t iso9660 -o loop $eFile $eMount" > syntax.txt |
Quote:
Thanks! |
In my expirence the scripts does not handle very well spaces in file names
Code:
sudo mount -o loop /home/abigail.dunning/Training/1994-2010\ Linux\ Journal\ Master\ Collection.iso /media/iso/1994-2010\ Linux\ Journal\ Master\ Collection |
Quote:
Right now I'm trying to troubleshoot with a file on the local system but no, all the ISOs are all on a network share and the environment is a shared small business Windows server. The users can't comprehend the concept that spaces could be a problem (and I'm trying to demonstrate that Linux can be a realistic option for this organization). I've escaped all the spaces with sed and when the command is run in the shell directly, all is well so there must be something unique to Nautilus causing this problem. Looks like I'm gonna have to come up with something in python or C if I can't resolve soon. |
Quote:
The following works for a single ISO file that does not have white-space in the filename: Code:
#!/bin/bash Code:
#!/bin/bash P.S. Obviously the scripts are missing code for error checking. |
Quote:
Code:
sudo mount -o loop /home/abigail.dunning/Training/1994-2010\ Linux\ Journal\ Master\ Collection.iso /media/iso/1994-2010\ Linux\ Journal\ Master\ Collection Code:
echo "sudo mount -o loop $eFile $eMount" > syntax.txt Quote:
|
Quote:
Code:
sudo mount -o loop "$eFile" "$eMount" &> error.log If you quote the variables like I have, above, the variables may contain any characters that are valid in pathnames (i.e. anything except NULs or zero bytes), and the command will work. (It is possible sudo won't work, depending on your configuration, if you've redirected standard input and/or standard output, but that'd show up as a sudo error anyway.) I work with files with all kinds of weird stuff in their names; sometimes with things that won't show up properly anywhere (like both UTF-8 and CP-1252 latin characters in the same file name). I can attest that if you always use double quotes with variable references, Bash scripts and Linux filesystem commands can handle any file name you can create. (The only exception I know of is when you must provide the file name in a string that is interpreted by a shell first. That case is solved by double-quoting the file name within the string, with a backslash added before ! " $ ` \ characters.) |
Quote:
So I did finally solve the mystery and it was all on me. The escaping/quoting was not the issue at all. It turned out that my call to the environmental variable $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS[0] resulted in a null terminator \0 character being sent to mount, following the first element (which mount didn't understand). This null terminator was not showing up in gEdit when echoing the command to execute to a file so this resulted in me being able to copy and paste from that file into the shell and the command getting executed successfully. Thanks again everyone! |
All times are GMT -5. The time now is 10:53 PM. |