Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open command and linux path problem 1

Status
Not open for further replies.

veteq

Technical User
Dec 7, 2004
23
CA
I am kinda confused on this one...(I am new to perl)

in linux I use a variable to hold the location of the log files

$WD_LOGDIR = /var/log/WS

when I try to incorporate this variable to the open command, it creates a file in the "current location" that included the path name.

open (FILEOUT, "\$WD_LOGDIR\\progfile.log") or ....

what am I missing?

please help

 
$WD_LOGDIR = '/var/log/WS';

open (FILEOUT, "< $WD_LOGDIR/progfile.log") || die "ERR\n";

The character "<" will tell the open to read instead of write to the file.

The character ">" will tell the open to write a new file instead of read from the file.

The characters ">>" will tell the open to append instead of read the file or write a new file.



Michael Libeson
 
Thank you Michael, I will try that....


Veteq
 
Sorry, I didn't post the correct line of code....


open (FILEOUT, ">> $WD_LOGDIR/progfile.log") or die "not foun...";

the $WD_LOGDIR is a shell specified location and varies from machine to machine...I need to get the linux value into perl and use that value in the open file path.....
 
that worked, thank you Micheal for all your help....appreciated


Veteq
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top