Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a script that I use for resizing a jpg and uploading it using ftp onto my webserver. Is there some way I can add this script to the nautilus right click menu so that I can just right click on a jpg(or multiple jpg's) and select upload and the script will do the rest?
Location: Montpellier, France, Europe, World, Solar System
Distribution: Debian Sarge, Fedora core 5 (i386 and x86_64)
Posts: 262
Rep:
Put that script in your nautilus-script folder (~/.gnome2/nautilus-scripts). It will then be accessible through right-click > script > scriptName.
You'll probably need to modify your script a little bit as nautilus scripts expect to read their arguments from an environment variable. As a starter example, here is a script I use for rotating jpeg files. For more info, http://g-scripts.sourceforge.net/ has some valuable scripts and tips.
Code:
#!/bin/bash
#####
# Nautilus script to rotate jpeg images.
#
# Put that script
# in your ~/.gnome2/nautilus-script folder. You can then use
# it from any folder after selecting the images your want to
# rotate with "right-click > scripts > rotateJpeg"
#
# Copyright 2005 Olivier Clavel
# Author: Olivier Clavel <contact AT retiz DOT com>
# Licence: GPL (http://www.gnu.org/licenses/gpl.txt)
# Depends: nautilus, libjpeg (jpegtran), gnome-utils (zenity), file
#######
# We set input field separator to "new line" so that we can safely read
# file name with spaces from $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
IFS="
"
# location of temporary directory for file rotation
TMPDIR="/tmp" # Temporary directory
# Test if a file has been selected
if [ $# -eq 0 ]; then
zenity --error --title="error" --text="You must select at least 1 file to process"
exit 1
fi
# Ask for desired clockwise rotation.
rotation=`zenity --title "JPEG rotation" --list --column "" --radiolist --column "Clockwise rotation in degrees" TRUE 90 FALSE 180 FALSE 270`
# If no rotation value was selected, user clicked cancel: exit
if [ -z "$rotation" ] ; then
exit;
fi
# Go for rotation
totalFiles=$#
processedFiles=0
(for name in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
do
# check if the file is jpeg
isJpeg=`file -bi "$name" | grep jpeg | wc -l`
if [ $isJpeg -eq 1 ] ; then
# Rotate the picture in a temporary file.
jpegtran -copy all -rotate $rotation "$name" > $TMPDIR/tmppict.jpeg
# Replace the original file with the rotated one.
mv $TMPDIR/tmppict.jpeg "$name"
fi
let "processedFiles++"
let "progress=processedFiles*100/totalFiles"
echo $progress
done) |
zenity --progress --auto-close --title="Images Rotation" --text="Processing images ..." --percentage=0
Thanks for the info! Before your post I actually discovered nautilus-actions. I think it is probably just a gui for putting scripts in the ~/.gnome2/nautilus-scripts directory!
Do you know what user the scripts run as? Is it the user who is logged in?
I have a script that resizes and uplaods pictures to a web server. It works perfectly when I run it from the command line but doesn't work through the menu, any idea where the error messages go? Can't find them in /var/log/messages.
Sorry for all the question!
Here is my script, it resizes the files ok but then when it tries to execute ./ftp.pl it fails.
Code:
#!/bin/sh
for FILE in $*
do
convert $FILE -resize 384x $FILE
done
./ftp.pl $*
OUT=$?
if [ $OUT -eq 0 ];then
zenity --info --info-text "Files Uploaded!"
else
zenity --info --info-text "Failed for some reason!"
fi
Location: Montpellier, France, Europe, World, Solar System
Distribution: Debian Sarge, Fedora core 5 (i386 and x86_64)
Posts: 262
Rep:
Change ./ftp.pl to an absolute path. I guess that is your problem.
For the other questions: yes, the script run as the loged in user. Those script are in a personal directory anyway in your home and are not shared with other users.
About standard output and error, that's the bad part: it does not go anywhere (at least nowhere I could find). I've found this messageadvising to run nautilus from a command line to get standard output and error in the same terminal. Unfortunately it does not work for me (nautilus launches a new window and exits).
Thanks I can't believe I missed that, it was late last night when I was playing with this ha ha!
It's a pity that you can't catch the output/error, it would greatly enhance this software. In my case if I had got a "file not found ./ftp.pl" message it would have made solving my problem a lot easier!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.