Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I need to execute a script from the nautilus-actions and then wait for any input from the user, who has to read what the script has done before the terminal disappears.

This is my current nautilus-actions configuration:

  • Runtime execution: gnome-terminal -x sh -c COMMAND
  • Make executable:
    • Path: gksudo
    • Parameters: chmod +x %F

This script makes a file executable (+x) but I'd like to actually see the chmod output, if any, before the terminal is closed. Can this be achieved?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

You could use read (see man page of your shell) to make the terminal wait for the user to press a key to indicate they have read the output. Unfortunately, read from dash is rather limited, so I'd recommend using bash for this.

read -s -n1 -p "Press any key to continue" will print the prompt to the terminal (-p), wait for any key to be pressed (-n1) and finally exit without printing the entered key (-s).

Adding that to your script gives your users all the time they need.

Update: To integrate the above into nautilus-actions, create a bash script you can then use as action in the configuration dialog.

The script would have to look something like the following.

#!/bin/bash
gksu chmod +x $1
read -s -n1 -p "Press any key to continue"

Calling that script with a file name as first parameter – just like you did before with chmod – will set the executable bit for that file, then wait for user input.

share|improve this answer
    
I have read about, well, read, but how can I integrate it into nautilus-actions? –  frapontillo Nov 24 '13 at 12:23
    
Added some information on how to do that to the post. –  drc Nov 24 '13 at 12:39
    
I imagined that would be a solution; but can't I do this in the single command passed by nautilus-actions? I have already tried thecommand -param; read -s -n1 -p "Press any key to continue" but that does not work. –  frapontillo Nov 24 '13 at 12:44
    
From what I can tell, nautilus-actions does not support multiple commands. Thus, more complex actions have to be wrapped in a script like the one in my post. –  drc Nov 24 '13 at 12:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.