andrew@resam.dk (Leif Andrew Rump) (03/21/91)
I'm creating a shell script that set up the DISPLAY environment variable: set remote = `who am i | grep "("` if "$remote" != "" then setenv DISPLAY cphxd3:0.0 endif I would like to make this shell script "global" so everybody could use it, but that means that "cphxd3:0.0" must be replaced with whatever the user is sitting at. I figured that a sed script could solve my problem but how? setenv DISPLAY `sed ??? $remote`:0.0 Leif Andrew Leif Andrew Rump, AmbraSoft A/S, Stroedamvej 50, DK-2100 Copenhagen OE, Denmark UUCP: andrew@ambra.dk, phone: +45 39 27 11 77 / Currently at Scandinavian Airline Systems =======/ UUCP: andrew@resam.dk, phone: +45 32 32 51 54 \ SAS, RESAM Project Office, CPHML-V, P.O.BOX 150, DK-2770 Kastrup, Denmark NOTICE: 'Cause of SendMail ConFiGuRation FaultS weee may experiienc ProBleeems wiiiiiiith our return add<zap> andrew@resam.dk whiccccch may BeCoMe sOmEthIng like <wheee>w@cph<click> !%#@# @$$%$%(&**&(^%$ $#%%^&)(&^T^%^%^^# login:
jik@athena.mit.edu (Jonathan I. Kamens) (03/22/91)
In article <1991Mar21.111919.4126@resam.dk>, andrew@resam.dk (Leif Andrew Rump) writes: |> set remote = `who am i | grep "("` set remote = `who am i | sed -n 's/^.*\(([^)]*:[^)]*)\).*$/\1/p'` |> if "$remote" != "" then |> setenv DISPLAY cphxd3:0.0 |> endif if ("$remote" != "") then setenv DISPLAY "$remote" endif |> I would like to make this shell script "global" so everybody could use it, You might want to read the section of the comp.unix.questions FAQ which discusses why shell scripts can't change their parents' environments. Unless you're planning on making this a file that people "source", rather than running as an executable shell script. If you don't have a copy of the FAQ and it has expired at your site, see the end of this message for instructions on how to get it. -- Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710 1. Via anonymous ftp from pit-manager.mit.edu (18.72.1.58), in the file /pub/usenet/comp.unix.questions/Frequently_Asked_Questions_about_Unix_-_with_Answers_[Monthly_posting] 2. Via mail archive server. Send mail to mail-server@pit-manager.mit.edu with a subject of send usenet/comp.unix.questions/Frequently_Asked_Questions_about_Unix_-_with_Answers_[Monthly_posting]
guy@auspex.auspex.com (Guy Harris) (03/27/91)
> set remote = `who am i | sed -n 's/^.*\(([^)]*:[^)]*)\).*$/\1/p'`
Not quite. Works fine if you're running from, say, an "xterm"; doesn't
work so fine if you're remotely logged in (i.e., it depends on an
"xterm"-style entry being in the parentheses, with a host name, colon,
and display name, and doesn't work if there's just a host name there).
If you're running from an "xterm", DISPLAY should already be set....
Of course, even if you change it to handle "rlogin"/"telnet" entries, it
may not do what you want if you remotely log in to machine A from your
workstation and then remotely log into machine B from machine A, because
it'll set DISPLAY to refer to machine A, not to your workstation....