LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Permission Denied, RHEL, dot command in a key binding, gconf-editor (http://www.linuxquestions.org/questions/linux-newbie-8/permission-denied-rhel-dot-command-in-a-key-binding-gconf-editor-4175455784/)

lanta 03-27-2013 08:33 AM

Permission Denied, RHEL, dot command in a key binding, gconf-editor
 
Trying to set up my F12 key to run a script named /foo/bar in a gnome-terminal (RHEL 5.9). Have typed /foo/bar in the value field of the keybinding_commands portion of apps->metacity using the gconf-editor and connected it to the F12 key in global_keybindings and it works well...except when I change /foo/bar to ". /foo/bar" (without the quotes; yes there's a space between the dot and the first slash). I want /foo/bar to run in the current shell because it makes changes to the environment.

When I try this, I get the following in a window:
There was an error running ". /foo/bar":
Failed to execute child process "." (Permission denied).
I find this odd because I can type those literal characters ". /foo/bar" in the terminal screen and it works properly.

I just want those literal characters to go to the gnome-terminal that has the input focus. What's happening behind the scenes to cause this behavior? Thanks.

pan64 03-27-2013 08:37 AM

but metacity is not a bash and does not understand . as bash. It wanted to find an executable named ., but it is actually a directory and cannot be executed.
From the other hand . <command> will work only in the current shell, other apps and GUI will not be affected.

lanta 03-27-2013 08:42 AM

Quote:

Originally Posted by pan64 (Post 4919872)
but metacity is not a bash and does not understand . as bash. It wanted to find an executable named ., but it is actually a directory and cannot be executed.
From the other hand . <command> will work only in the current shell, other apps and GUI will not be affected.

I see. Thanks!

Would there be a different approach using gconf-editor to achieve my desired effect then, anyone?

pan64 03-27-2013 10:13 AM

what kind of changes do you need?

lanta 03-27-2013 10:42 AM

Quote:

Originally Posted by pan64 (Post 4919921)
what kind of changes do you need?

The functionality I'm after is to be able to click in a running gnome-terminal window (to give it the input focus) and hit a key (such as F12) and have gnome/metacity/(something else?) place arbitrary characters in that window at the current cursor position so that I can subsequently hit the Enter key and have those characters executed as a command.

Using the date command as an example, if I'm logged into a bash shell within a gnome-terminal and I'm at the command prompt:
$ _
I'd like to be able to hit F12 and have the characters 'd' 'a' 't' 'e' placed at the cursor:
$ date_
at which point I'd just hit the Enter key to execute that command. (It would also be fine if I did not have to hit the Enter key and the command was executed immediately.)

The actual characters I'd be typing are not 'date' but a fairly long string that I find myself typing several times a day. The reason I'd like this tied to an F-key (rather than, for example, just creating an alias for it in .bashrc) is that I'm most often typing this string after 'su-ing' to another user with a hyphen (eg 'su -' or 'su - jdoe') and I don't want to muck with root's or jdoe's .bashrc files (or any of their files for that matter).

And indeed, as mentioned originally, the first two characters need to be a dot followed by a space so that the command is executed in the current shell, not a subshell.

RHEL 5.9
Gnome 2.16.0
Metacity 2.16.0

pan64 03-27-2013 11:54 AM

I would suggest you to create aliases, and create a file for example <some dir>/.myaliases.
When you execute a su - <anyone> first you source your aliases (that is . <some dir>/.myaliases) and you will reach all your aliases
remember, the file in ~ is accessible only by the owner, so probably you need to find another place.
a more interesting solution can be to modify the common bashrc to use your aliases in case the current terminal (exists) and is owned by you (that will be owned by the creator and will not be changed after a su -).

lanta 03-27-2013 12:12 PM

Quote:

Originally Posted by pan64 (Post 4919986)
I would suggest you to create aliases, and create a file for example <some dir>/.myaliases.
When you execute a su - <anyone> first you source your aliases (that is . <some dir>/.myaliases) and you will reach all your aliases
remember, the file in ~ is accessible only by the owner, so probably you need to find another place.
a more interesting solution can be to modify the common bashrc to use your aliases in case the current terminal (exists) and is owned by you (that will be owned by the creator and will not be changed after a su -).

Thanks for the thoughtful bypass, pan64. That seems like a viable way to accomplish the specific task at hand.

However, I'll leave it open for possibly others to comment on a more general solution that would involve hitting just one key. Perhaps my overall approach (gconf-editor/metacity branch) is misguided.


All times are GMT -5. The time now is 09:00 AM.