perl variable assingment


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl variable assingment
# 1  
Old 01-29-2002
perl variable assingment

I want to assign the current user to a variable in my perl script.

My first attempt using Solaris 8 (perl 5) is:

$VAR = system(logname);

However, this assigns 0 to $VAR, and outputs the user to the screen. Does anyone know the command that I need?

Thanks,
seismic_willy
# 2  
Old 01-29-2002
your VAR is getting the return value of the system call, 0 for success try this to get the logname into the variable

#!/usr/bin/perl

$var=`logname`;
print $var;
# 3  
Old 01-29-2002
Thanks again edog.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script Assingment!

Q 1. Write a shell script to print the following pattern upto n (specified by user)- @ @@ @@@ @@@@ @@@ @@ @ Please help! :) (1 Reply)
Discussion started by: heatedline
1 Replies

2. Shell Programming and Scripting

Perl help - how to assign output of perl to variable

Hi, guys, i have a script i inherited from a coworker but i'm not perl savy. The script works but i would like it to work better. I want to run this command ./ciscomgrtest.pl -r "show version" -h hosts.router and have the script goto each router in the hosts.router file and run the command... (2 Replies)
Discussion started by: whipuras
2 Replies

3. Shell Programming and Scripting

[Perl] Split lines into array - variable line items - variable no of lines.

Hi, I have the following lines that I would like to see in an array for easy comparisons and printing: Example 1: field1,field2,field3,field4,field5 value1,value2,value3,value4,value5Example 2: field1,field3,field4,field2,field5,field6,field7... (7 Replies)
Discussion started by: ejdv
7 Replies

4. Shell Programming and Scripting

PERL : Use of a variable in a tr

Hi, I want to count the number of occurences of a character in a string variable ($str). The character is stored in a another variable ($sepchr). I am using tr as : $count = ($str =~ tr/$sepchr//); This did not work. I found in another thread about using eval. I used eval as : ... (13 Replies)
Discussion started by: sinpeak
13 Replies

5. Shell Programming and Scripting

perl - how can we name a variable base on value of another variable

Hey all, perl - how can we name a variable base on the value of another variable? for example in ksh/bash we do : export c="100" export x`echo $c`=2000 echo $x100 x100=2000 is it possible to do something similar for perl? I already tried many ways but nothing is working. I am... (3 Replies)
Discussion started by: cacm1975
3 Replies

6. Shell Programming and Scripting

perl get variable value ???

hi i have following code my $a1 = "A" ; my $a2 = "B" ; my $a3 = "C" ; foreach my $k ( 1,2,3 ) { my $msg = ${a{$k}} # this should be at runtime i am creating variable a1 and assigning it value to msg . print "$msg\n" ; } above thing is not working !!! i want when k = 1... (4 Replies)
Discussion started by: zedex
4 Replies

7. Shell Programming and Scripting

Multiple variable in a variable in Perl

Hi All, I am trying to convert the below Csh while loop into Perl while loop but the problem is that in this csh script, i have 2 variables inside a variable -> $count is a variable {SB$count} as a whole is another variable. Csh is able to assign values to such variable like the below but i do... (3 Replies)
Discussion started by: Raynon
3 Replies

8. Shell Programming and Scripting

Perl - Command assingment to variable.

Hi How do i assign the output of a unix command to a variable ? say i want the whoami output to be assigned to a variable? Thanks (2 Replies)
Discussion started by: PrasannaKS
2 Replies

9. UNIX for Dummies Questions & Answers

need help for an assingment

i have to do an assingment using mailx, where can i find info on mailx? *yes i read the rules, so i am not asking for the asnwers, just need to learn about mailx more (1 Reply)
Discussion started by: punk_87
1 Replies

10. Shell Programming and Scripting

Query string assingment for other variable in PERL

Hi friends, I want to use query string value to another variable but it gives following error when I use it with print out command, Insecure dependency in open while running with -T switch at C:/Program Files/Apache Group/Apache2/cgi-bin/cdr_findere.pl line 119. My code as follows, my... (0 Replies)
Discussion started by: maheshsri
0 Replies
Login or Register to Ask a Question