Perl help

M

Mukesh

$host=`hostname`
$date=`date +%b%d%g`
$logdir="$LOGBASEDIR/$date/$host"
i have set the logdir like this but it is not printing the date & host but just
displaying the host & date variables.how to set them.Please help me.
 
A

Anno Siegel

Mukesh said:
$host=`hostname`
$date=`date +%b%d%g`
$logdir="$LOGBASEDIR/$date/$host"
i have set the logdir like this but it is not printing the date & host but just
displaying the host & date variables.how to set them.Please help me.

Your code only contains variable assignments, no output statements.
You error concerns output statements. Show those.

Anno
 
A

Anno Siegel

Mukesh said:
$host=`hostname`
$date=`date +%b%d%g`
$logdir="$LOGBASEDIR/$date/$host"
i have set the logdir like this but it is not printing the date & host but just
displaying the host & date variables.how to set them.Please help me.

Your code only contains variable assignments, no output statements.
You problem concerns output. Show those.

Anno
 
B

Brian McCauley

Mukesh said:
Subject: Perl help

Please put the subject of your post in the Subject of your post.
$host=`hostname`
$date=`date +%b%d%g`
$logdir="$LOGBASEDIR/$date/$host"
i have set the logdir like this but it is not printing the date & host but just
displaying the host & date variables.

That statement makes no sense.

And as Anno points out even if we try to guess what it means, any
possible interpretation must refer to some other code since the code you
post would have no observable behaviour.

Hint: Remember that `` returns the _whole_ output of the command,
including any control characters, like say, a newline at the end.
 
T

Tad McClellan

Mukesh said:
Subject: Perl help


Please put the subject of your article in the Subject of your article.

There are a hundred messages a day here, nearly *all* of
them wanting Perl help.

Your subject contains no useful information nor does it indicate
what your article is about.

Have you seen the Posting Guidelines that are posted here frequently?

$host=`hostname`


Syntax error, no semicolon.

We must see the *actual code* if we are to debug the code!

You should copy/paste working code into your article.

Have you seen the Posting Guidelines that are posted here frequently?

$date=`date +%b%d%g`


To do that in native Perl instead of shelling out:

perldoc -f localtime

$logdir="$LOGBASEDIR/$date/$host"
i have set the logdir like this but it is not printing


Of course it isn't, there are no print() statements in your code!

You must have some statements in your code that generate output
before you will see any output from your program.

the date & host but just
displaying the host & date variables.


Huh?

It is not "printing" them, but it *is* "displaying" them?

What is the difference?

how to set them.


How to set what?

How to set the hostname or how to set the $host variable?

How to set the date or how to set the $date variable?

Please help me.


Help us help you by giving us what we need to help you, namely
real code that we can run that duplicates the problem.

You will eventually also need to know about:

perldoc -f chomp
 
G

Glenn Jackman

At 2005-03-01 04:57AM said:
$host=`hostname`
$date=`date +%b%d%g`
$logdir="$LOGBASEDIR/$date/$host"
i have set the logdir like this but it is not printing the date & host but just
displaying the host & date variables.how to set them.Please help me.

Use the %ENV hash to access environment variables.

use Sys::Hostname;
use POSIX qw( strftime );
my $logdir = $ENV{LOGBASEDIR} . '/' .
strftime('%b%d%g', localtime) . '/' .
hostname();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top