开发者

File IO on a remote Windows system

开发者 https://www.devze.com 2023-04-07 00:14 出处:网络
Given a Perl script that can be running on unix or Windows, how can I 开发者_Go百科best read/write to a file on awindows host? Is there anything similar to File::Remote? I would try to mount the remot

Given a Perl script that can be running on unix or Windows, how can I 开发者_Go百科best read/write to a file on a windows host? Is there anything similar to File::Remote?


I would try to mount the remote folder and then use the standard perl functions:

use constant W_REMOTE_FOLDER = '\\server\share';
use constant W_LOCAL_FOLDER = 'x:\share\';
use constant L_REMOTE_FOLDER = 'smb://server/share';
use constant L_LOCAL_FOLDER = '/mnt/share/';

my $localfolder = '';

if ($am_i_windows)
{
    system('net use ...');
    $localfolder = W_LOCAL_FOLDER;
}
if ($am_i_linux)
{
    system('mount ...');
    $localfolder = L_LOCAL_FOLDER;
}
die "What am I? if ($localfolder eq '');


open(HANDLE, "$localfolder/$filename");
# read/write (...)
close(HANDLE);
0

精彩评论

暂无评论...
验证码 换一张
取 消