CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
perl write file name issue Unix vs. Win

 



rasterize80
New User

May 16, 2011, 1:54 PM

Post #1 of 6 (1116 views)
perl write file name issue Unix vs. Win Can't Post

I just want to write a simple log file with a time stamp. This works fine, and the name works fine... in UNIX. When I view the file in windows, it shortens the name. e.g.:
test_Mon_May_16_15:24:33_2011_log.txt

gets changed to:
TEST_1~1.TXT

Why does this happen? Windows XP doesn't have file length limitations like the olden days. I've searched across several forums and can't seem to find an answer. ... help!

Perl 5.8.4 for sun4-solaris-64int
***********************
#! /usr/bin/perl -w
use strict;

my $lt = localtime;
$lt = s/ /_/g;
my $outputFile = $ENV{HOME} . "test_" . $lt . ".txt";

open (OFH, "> $outputFile") or die "could not open $outputFile";
print OFH "Testing 1 2 3\nTimeStamp: $lt";
close (OFH);


BillKSmith
Veteran

May 16, 2011, 3:44 PM

Post #2 of 6 (1106 views)
Re: [rasterize80] perl write file name issue Unix vs. Win [In reply to] Can't Post

How are you viewing the file name in XP? All windows files have two names. The first is what you expect. The other conforms to the ancient DOS 8.3 format. (Refer to the /X option of the windows DIR command.) You are showing the DOS formatted name.

Also note:

Typo in line 5.

By default, XP does not have an environment variable 'HOME'.

Spaces are allowed in windows file names.

Colons are not allowed in file names.
Good Luck,
Bill


rasterize80
New User

May 17, 2011, 6:25 AM

Post #3 of 6 (1086 views)
Re: [BillKSmith] perl write file name issue Unix vs. Win [In reply to] Can't Post

Thanks for the response, I guess I should have clarified a little better. I am writing my script on a Unix system, and running the script on the Unix system. (I won't run the script on Win) This writes the log file to my home drive which is accessible via Unix or Windows. When I go to view the log file on windows (to eventually use in excel) I see the shortened file name, as described previously, in the windows file explorer.


FishMonger
Veteran / Moderator

May 17, 2011, 7:02 AM

Post #4 of 6 (1086 views)
Re: [rasterize80] perl write file name issue Unix vs. Win [In reply to] Can't Post

Sounds like a Samba configuration problem.

Add this line to the global section of smb.conf

Quote
mangled names = no



rasterize80
New User

May 17, 2011, 9:55 AM

Post #5 of 6 (1074 views)
Re: [FishMonger] perl write file name issue Unix vs. Win [In reply to] Can't Post

I'm guessing I don't have privileges to edit a config file like the one you're describing. Nor do I see it anywhere that I have access to. :/


rasterize80
New User

May 17, 2011, 10:38 AM

Post #6 of 6 (1071 views)
Re: [rasterize80] perl write file name issue Unix vs. Win [In reply to] Can't Post

Well I'm stupid... had I more thoroughly read BillKSmith's reply and really let it sink in, I would have realized he solved the problem with the colon in windows filenames comment. ugh sorry for being thickheaded!

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives