Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


Search this Thread
Old 12-10-2004, 05:27 AM   #1
Registered: Aug 2003
Location: Edinburgh
Distribution: Server: Gentoo2004; Desktop: Ubuntu
Posts: 720

Rep: Reputation: 30
what is the echo command in perl?


I'm writing a perl script at the moment to check my users quotas. I have used bash scripts before, and would like to know the equivilent perl command to the bash "echo" command.

The reason being that part of my code is to echo to the outcome of a command:

echo "$(repquota -a)" > temp
What will this be in perl?

Thanks in advance.
Old 12-10-2004, 05:49 AM   #2
Registered: Sep 2004
Location: India
Distribution: Solaris 9, FreeBSD 4.10, Slackware, RedHat, Knoppix,
Posts: 84

Rep: Reputation: 15
hey hamish,

u can use "print" or even echo itself.

#!/usr/bin/perl -w
my @array = `repquota -a`;
foreach my $record(@array)
print "$record\n";

that's it..!!!

Old 12-10-2004, 11:49 AM   #3
Registered: Sep 2004
Location: south texas
Distribution: fedora core 3,4; gentoo
Posts: 192

Rep: Reputation: 30
the system() functionis also helpful if you just need to run some commands.

system("echo $(repquota -a`");

it basically just inserts what is betweent he "" into a command line and enters it
Old 12-14-2004, 06:53 AM   #4
LQ Newbie
Registered: Jun 2003
Posts: 14

Rep: Reputation: 0
you can also use, printf("\n"); like what we do in C
Old 12-14-2004, 07:21 AM   #5
Senior Member
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,288

Rep: Reputation: 174Reputation: 174
firstly why are you doing
echo "$(repquota -a)" > temp
why not simply
repquota -a > temp

you can't simply print the output of a command
(I assume you mean calling a system command from perl?)

you can use sytem which will print out anyway.

if you want to save to a file you can use system
system("repquota -a > temp")
or using 'open' in perl
you can do operations line by line of the output:

(this example will simply print output from find)

    open OUT, "2>&1  /usr/bin/find .  |";
    print  while (<OUT>);
Old 12-14-2004, 08:31 AM   #6
Registered: Aug 2003
Location: Edinburgh
Distribution: Server: Gentoo2004; Desktop: Ubuntu
Posts: 720

Original Poster
Rep: Reputation: 30

thanks for all the feedback guys. I now have it working.



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
Bash Script, no new line for echo command jorisb Linux - General 5 11-05-2005 12:08 AM
echo command to a running process happy78 Programming 18 09-06-2005 01:03 PM
Bash Scripting - echo command question gbhil Programming 2 04-27-2005 07:27 PM
CGI script problem: Send/Expect command echo on webpage rajatgarg Programming 2 07-11-2004 04:38 PM
echo command peculiarity eallen Linux - General 3 02-11-2003 05:30 PM

All times are GMT -5. The time now is 12:33 AM.

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