LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


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

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


Hey

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:

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

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

Rep: Reputation: 16
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..!!!

Cheers
 
Old 12-10-2004, 11:49 AM   #3
sirclif
Member
 
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
mayur
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
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
firstly why are you doing
Quote:
echo "$(repquota -a)" > temp
why not simply
Code:
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
Code:
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)

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

Original Poster
Rep: Reputation: 30
hey

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

Cheers
Hamish
 
  


Reply



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration