Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

a little OT - smbfs weirdness

by ralphie (Friar)
on Oct 26, 2001 at 00:12 UTC ( [id://121530]=perlquestion: print w/replies, xml ) Need Help??

ralphie has asked for the wisdom of the Perl Monks concerning the following question:

i've been rewriting a script that i use to parse the (text) results file from a lab instrument and insert the results in a postgresql database. the machine on which the log is stored is an nt 4 workstation, i mount a read-only share to read the file on the linux box i use to run the script (smbfs 2.2.1 on a debian box)

my decision to rewrite the script was motivated by some difficulty in getting certain sets of lines to parse appropriately ... now that i've been starting to debug the structure of the new version i've noticed that if i step through the script using ptkdb to reach a certain point the file is read appropriately, but if i set that same point in the script as a break point and run straight to it i'm a line further down in the source file. this led me to start wondering how smbfs handles new lines. i've done some looking around and discovered that samba in its default configuration makes no changes in the line endings when creating a share, but i haven't been able to find anything about how smbfs handles newlines when mounting nt shares. i had a klunky little procedure that i had created in the previous version to iron out anomalous behavior, but i'm not sure that i caught all of that and i'd like to make this version a little cleaner. has anyone else dealt with this?

Replies are listed 'Best First'.
Re: a little OT - smbfs weirdness
by Erik Hensema (Sexton) on Oct 26, 2001 at 00:52 UTC

    AFAIK Samba doesn't do any conversion on line-endings. You're probably looking at a \r\n <-> \n conversion problem. As you (should) know Dos and NT use \r\n as end-of-line and Unix uses just \n.

    Maybe you could use something like this (I never tried it though):

    $/ = "\r\n"; while(<FILE>) { chomp; blabla; }

    If this doesn't work you may want to open the file throug a dos2unix pipe:

    open FILE, "dos2unix $file|" or die;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://121530]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2024-04-19 09:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found