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

DBMS and network drive

by hnd (Scribe)
on Aug 01, 2009 at 07:07 UTC ( [id://785061]=perlquestion: print w/replies, xml ) Need Help??

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

hello monks.......
our DBMS faculty told us to save our work (the SQL commands) into a notepad file in the network drive....
so i thought "why not automate it???"
for this i made a perl script 'use'ing DBI and file handling that queries the SQL server and saves the queries into a notepad file.... (since the script is absurdly simple and works so no need of posting it here)
now the problem is how do i upload my file on the network drive?
please help.... :)
UPDATE the network drive is NAS most probably.... dont know exactly....
=====================================================
i'am worst at what do best and for this gift i fell blessed...
i found it hard it's hard to find well whatever
NEVERMIND

Replies are listed 'Best First'.
Re: DBMS and network drive
by tokpela (Chaplain) on Aug 01, 2009 at 13:19 UTC

    This is pretty easy really - you just open the file using the UNC.

    Basically, opening a file on a network drive can be accomplished by using the UNC filepath:

    my $unc = '//10.1.0.22/path/to/use'; open(my $fh, $unc) or die "[Error] COULD NOT OPEN FILE: [$unc] - [$!]" +;

    If you need to connect to the network drive you have two options.

    One option is to create a mapped drive.

    You could do this directly through Windows using the NET USE command:

    net use x: \\computer name\share name
    or
    net use x: \\computer name\share name password /user:username
    or a permanent map
    net use x: \\computer name\share name password /user:username /persist +ent:yes

    You could also accomplish this same thing using Win32::FileOp by using the Map routine:

    my $drive = 'X'; my $unc = '//10.1.0.22/path/to/use' my $user = 'user'; my $pass = 'xyz'; Map $drive => $unc, { username => $user, passwd => $pass };

    Finally, the second option is to connect to the network drive directly in the program which can be accomplished by using the Win32::FileOp Connect routine:

    my $drive = 'X'; my $unc = '//10.1.0.22/path/to/use' my $user = 'user'; my $pass = 'xyz'; Connect $drive => $unc, { username => $user, passwd => $pass };

Re: DBMS and network drive
by cdarke (Prior) on Aug 01, 2009 at 08:55 UTC
    Presumably by "notepad file" you mean a Windows plain text file, or are you using some special feature of Notepad that I have missed?
    Anyway, assuming you are just using open and not any OLE magic, then it is just a question of determining the correct path name for the file in open. The fact that a drive is networked should be transparent at that level.
      so this means if i do
      open(<filehandle>,<network path>);
      i will be open a file on the network drive???
      can you give an example depecting how to 'open' a file in the network drive???
      and i've used just a simple notepad file no OLE magic...
      =====================================================
      i'am worst at what do best and for this gift i fell blessed...
      i found it hard it's hard to find well whatever
      NEVERMIND
        You really should RTFM.
Re: DBMS and network drive
by Anonymous Monk on Aug 01, 2009 at 07:36 UTC
    What is a "network drive"? SMB? NAS? //server/path/blah/blah?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-03-28 12:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found