| | |
help with a script
Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2008
Posts: 2
Reputation:
Solved Threads: 0
hey
I need a script to set a display to users ip's, I just need help putting it togther
the command i need to run is
setenv DISPLAY ipaddress:0.0
And i've got this to grab the ip and pop in the :0.0:
who|grep user | awk '{print $6}' |sed 's/(//g' | sed s/)/:0.0/g'
How do i now get the results of the above into one script that i can just run it will take ipaddress:0.0 and run the command ?
thx
I need a script to set a display to users ip's, I just need help putting it togther
the command i need to run is
setenv DISPLAY ipaddress:0.0
And i've got this to grab the ip and pop in the :0.0:
who|grep user | awk '{print $6}' |sed 's/(//g' | sed s/)/:0.0/g'
How do i now get the results of the above into one script that i can just run it will take ipaddress:0.0 and run the command ?
thx
•
•
Join Date: Oct 2007
Posts: 399
Reputation:
Solved Threads: 47
Hey There,
This might help, in bash:
in sh or a shell that doesn't support the $() builtin, you could do:
Just add that line anywhere in your shell script. $1 would be the first arg passed to it, so you could call it like:
./yourscript username
Or whatever else you wanted to with it.
Hope that helps
, Mike
This might help, in bash:
Shell Scripting Syntax (Toggle Plain Text)
setenv DISPLAY $(who|grep $1 | awk '{print $6}' |sed 's/(//g' | sed 's/)/:0.0/g')
in sh or a shell that doesn't support the $() builtin, you could do:
Shell Scripting Syntax (Toggle Plain Text)
setenv DISPLAY `who|grep $1 | awk '{print $6}' |sed 's/(//g' | sed 's/)/:0.0/g'`
Just add that line anywhere in your shell script. $1 would be the first arg passed to it, so you could call it like:
./yourscript username
Or whatever else you wanted to with it.
Hope that helps

, Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
•
•
Join Date: Oct 2007
Posts: 399
Reputation:
Solved Threads: 47
That's right - also change "setenv" to "export" -- Man - I'm on a roll - time to slow down - I was concentrating on solving you're getting back the value I completely forgot that your csh "setenv" wouldn't work in bash and just pasted it between the extraction part. Good catch 
Thanks
, Mike

Thanks

, Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
![]() |
Similar Threads
- Clean Previous Next Script for MySQL results (PHP)
- The name for the Resize Button to ad to Script (HTML and CSS)
- Random Programming Script (Computer Science)
- Importing SQL Script File - Urgent !! (Database Design)
- Script problems with IE (Web Browsers)
- Help with shell script to auto gzip a .sql dump after backup (Shell Scripting)
- Adding mutiple PC's to an OU via script? (Windows NT / 2000 / XP)
- Table of Contents Script (Java)
- ASP slow-down server script (ASP)
Other Threads in the Shell Scripting Forum
- Previous Thread: shell script to generate pdf
- Next Thread: SED: Conditionally removing \n
| Thread Tools | Search this Thread |





