LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 07-21-2011, 06:10 AM   #1
casualzone
Member
 
Registered: Jan 2010
Posts: 189

Rep: Reputation: 15
store the return value of $DISPLAY into my perl script


I want to store the return value of $DISPLAY into my perl script. I am new in perl script

echo $DISPLAY

how could i make it?

#! /apps/perl/bin/perl
$session = `echo $DISPLAY`;
print "$session\n";

but nothing come out

------------
in linux xterm

echo $DISPLAY
-->return
:0
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 07-21-2011, 06:22 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,378

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
that's a real horrible way to do what you want, do it properly - http://perldoc.perl.org/Env.html
 
2 members found this post helpful.
Old 07-22-2011, 12:39 AM   #3
casualzone
Member
 
Registered: Jan 2010
Posts: 189

Original Poster
Rep: Reputation: 15
Wow, it is a much easier way

use Env qw( $DISPLAY );
print("\nMy session = $DISPLAY\n";

many thanks!

to find linux variable, type env in xterm
 
Old 07-22-2011, 12:48 AM   #4
casualzone
Member
 
Registered: Jan 2010
Posts: 189

Original Poster
Rep: Reputation: 15
#! /apps/perl/bin/perl
use Env qw( $DISPLAY $HOST);
print("\nMy hostname = $HOST\n") ;
print("\nMy session = $DISPLAY\n") ;
$NEWDISPLAY = join("", "$HOST","$DISPLAY");
print("\nMy new display = $NEWDISPLAY\n" ) ;
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with return function value in perl shifter Programming 2 02-23-2010 10:04 PM
dpkg return error :post installation script return an error code (1) grimfold Debian 2 09-10-2009 01:55 PM
HELP!! Perl script to display drop down menu domquem Programming 3 06-03-2005 11:26 AM
Converting a Windows Perl script to a Linux Perl script. rubbercash Programming 2 07-19-2004 10:22 AM
unescaping a carriage return in perl acid_kewpie Programming 10 09-20-2002 02:20 PM


All times are GMT -5. The time now is 11:27 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration