Frage

My Problem

My core issue is I need to start the gnome-keyring-daemon from c shell. In bash, it's quite easy:

> export `gnome-keyring-daemon`

which is the equivalent of:

> export GNOME_KEYRING_SOCKET=/tmp/0123.1.sds/keyring-abcdef/socket GNOME_KEYRING_PID=012345

My goal is to get the same functionality in c shell, but my command line skills aren't up to the task.

What I Tried

If I run

echo gnome-keyring-daemon | tr '=' ' ' | sed s/GNOME_KEYRING_SOCKET/setenv\ GNOME_KEYRING_SOCKET/ | sed s/GNOME_KEYRING_PID/\;setenv\ GNOME_KEYRING_PID/

I get a good start:

setenv GNOME_KEYRING_SOCKET /tmp/0123.1.sds/keyring-abcdef/socket ;setenv GNOME_KEYRING_PID 012345

Despite the fact that i can copy and paste that output to the command line and get it to work, if I enclose that statement in ticks to get it working on one line I get the following error:

Invalid null command.

I researched it and saw it is related to a newline sneaking in that needs to be escaped or removed; however, I still get the error even after adding replace commands for \r and \n like so:

> | tr '\r' ' ' | tr '\n' ' ' |

What I'm looking for

I really just need anything I can add to my .cshrc file that will start the gnome-keyring-daemon. If I'm on the wrong track, I'd be happy to hear an alternative approach.

Thanks!

One Last Thing I Tried

To really simplify this I've also tried to just set one variable at a time:

setenv GNOME_KEYRING_PID `echo -n `gnome-keyring-daemon` | sed 's/.*GNOME_KEYRING_PID=\([0-9]\+\)/\1/'`

Which also gives me a "Invalid null command." message despite the fact that this works:

setenv GNOME_KEYRING_PID `echo '1234'`
War es hilfreich?

Lösung

Thanks to @shelter and @gbulmer for your help. I really hate answering my own question, but this may help someone in the future...

In the end I updated my C Shell script to set the variables on multiple separate lines:

set gkd = `gnome-keyring-daemon`

set pid = `echo $gkd |  sed 's/.*GNOME_KEYRING_PID=\([0-9]\+\)/\1/'`
set socket = `echo $gkd | sed 's/GNOME_KEYRING_SOCKET=\([^ ]\+\).\+/\1/'`
setenv GNOME_KEYRING_PID $pid
setenv GNOME_KEYRING_SOCKET $socket

Andere Tipps

Have you tried echo -n gnome-keyring-daemon | ... echo adds a newline

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top