Click to See Complete Forum and Search --> : simple Nautilus script
seraph47
12-18-2007, 05:17 PM
Hi, I'm having trouble trying to create a Nautilus script.
What I'm trying to do is open a selected folder in a terminal, and check any sfv files that may be present.
Here is the command that I have to open the folder in a terminal:
base="`echo $NAUTILUS_SCRIPT_CURRENT_URI | cut -d'/' -f3- | sed 's/%20/ /g'`"
if [ -z "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" ]; then
dir="$base"
else
while [ ! -z "$1" -a ! -d "$base/$1" ]; do shift; done
dir="$base/$1"
fi
gnome-terminal --working-directory="$dir"
When I try to add 'cksfv -r -L', it doesnt run that command. Any help would be greatly appreciated.
Thanks in advance.
seraph47
12-25-2007, 11:58 PM
Anyone have any suggestions?
Any help would be greatly appreciated, thanks.
why don't you just use
cd <search_directory>;find | grep \.sfv\$
seraph47
12-27-2007, 11:58 PM
why don't you just use
cd <search_directory>;find | grep \.sfv\$
Thanks for your response.
However, I'm not trying to find a .sfv file, as I already know that there is one in every folder.
I'm trying to see if all the files pass CRC and are not corrupted by running the command 'cksfv -r -L'
well you need a crc to compare against.
where is that crc in your case ?
seraph47
12-28-2007, 11:12 AM
well you need a crc to compare against.
where is that crc in your case ?
SFV files are simple text files that contain the crc for given files.
All I'm trying to run is run one command when the terminal pops up,
'cksfv -r -L'. That's ALL I'm trying to do; everything else in in place.
I already have the code to open a terminal in a given directory, now I just have to figure out how to run that command successfully.
And that's where I'm having problems.
bwkaz
12-28-2007, 08:41 PM
If you look in the manpage for the terminal emulator you're using, you'll find an argument that you have to pass it so it runs a given command instead of starting up a shell (which is the default). For instance, xterm uses -e (so xterm -e "ls ; read x" will fire up a new xterm, and inside it, list the current directory and then wait for you to hit return; then the xterm will close).
Some terminal emulators also have an option that you can use to make them stay up after the program you tell them to run exits, until you hit a key (or whatever). Eterm, for instance, also uses -e for "run this command", but it also has the --pause option, which makes it wait for any keyboard input before exiting. (Eterm's -e option also doesn't require quotes, so you have to put --pause before -e.)
seraph47
12-29-2007, 12:53 PM
Thanks for that info bwkaz.
I'm using the bash shell, and I thought the -x flag would do the trick.
I'll look into it again, but this is what I currently have:
#!/bin/bash
# This script either opens in the current directory,
# or in the selected directory,
# and checks an SFV file
# From Chris Picton
# Replaces a Script by Martin Enlund
# Modified to work with spaces in path by Christophe Combelles
base="`echo $NAUTILUS_SCRIPT_CURRENT_URI | cut -d'/' -f3- | sed 's/%20/ /g'`"
if [ -z "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" ]; then
dir="$base"
else
while [ ! -z "$1" -a ! -d "$base/$1" ]; do shift; done
dir="$base/$1"
fi
gnome-terminal --working-directory="$dir"
-x cksfv -r -L
bwkaz
12-30-2007, 02:34 PM
If the -x option is the correct one for gnome-terminal (note: it's not bash that you have to look at, it's the terminal emulator), then you probably need to put it on the same line as the call to gnome-terminal. Or at least put a line continuation (backslash-newline) on the gnome-terminal line.
Otherwise the shell won't know that the -x is supposed to be part of the gnome-terminal command, and it'll try to run it (on its own, which will fail) after the terminal exits...
seraph47
01-01-2008, 05:39 PM
Thanks for that info, I'll keep on tinkering with it