
aasadourian
New User
Mar 15, 2007, 1:14 PM
Post #1 of 4
(1886 views)
|
filehandle directory path unix vs. windows
|
Can't Post
|
|
Hello World I have a perl script that runs in unix and windows environment. I create a filehandle and populate it with data. In my script I chdir to the /unix/path where I want to save my data. But when I'm in windows and the script is called it does not know the /unix/path. I want the file to be written to this /unix/path no matter what OS i'm in. Does anyone have an idea of what I need to do to distinguish between unix and windows? Thank you for your time, aasadourian. ----sample code----- #! /usr/bin/perl ########## Variables ####### $ACTION_DATE = localtime; $MACHINE = `hostname`; $OP_KIND = "$ENV{'CLEARCASE_OP_KIND'}"; $USER = "$ENV{'CLEARCASE_USER'}"; $ELEMENT_NAME = "$ENV{'CLEARCASE_PN'}"; $ELEMENT = "$ENV{'CLEARCASE_XPN'}"; ############################# $logFile = "trgCOLog"; if (($OP_KIND eq "checkout") || ($OP_KIND eq "checkin")) { print "Inside $OP_KIND loop\n" if ( $debug ); chdir("/home/adm/temp") || die "Can't move to /home/adm/temp, error: $!\n"; open(LOG, ">> $logFile") || die $!; print "File exists...\n" if ( $debug ); # write output to a file print LOG "*****************\n"; print LOG "NEW CO/CI EVENT\n"; print LOG "Element: $ELEMENT\n"; print LOG "Element Name: $ELEMENT_NAME\n"; print LOG "Performed By: $USER\n"; print LOG "Machine: $MACHINE"; print LOG "Date: $ACTION_DATE\n"; close(LOG) || die "Can't close: $!"; } # end of co/ci exit 0;
(This post was edited by aasadourian on Mar 16, 2007, 9:02 AM)
|