windows下netrc文件

本文介绍了如何设置.netrc文件来存储登录凭据,以便于访问远程LabKey服务器及进行FTP等操作。文中详细解释了在不同操作系统中创建和配置该文件的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Overview

A netrc file is used to hold credentials necessary to login to your labkey server and authorize access to data stored there. The netrc file contains configuration and autologin information for the File Transfer Protocol client (FTP) and other programs. It may be used when working with SAS Macros, Using Java for Programmatic QC Scripts or using the Rlabkey package.

If you receive "unauthorized" error messages when trying to retrieve data from a remote server you should check that your netrc file is configured correctly, you have an entry for that remote machine, and the login credentials are correct.

Set up a .netrc or _netrc file

On a UNIX or Linux system this file should be named .netrc (dot netrc) and on Windows it should be named_netrc (underscore netrc). The file should be located in your home directory and the permissionson the file should be unreadable for everyone except you.

To create the _netrc on a Windows machine, first create an environment variable called ’HOME’that is set to your home directory (c:/Users/<User-Name> on Vista or Windows 7) or any directory you want touse. Two equivalent examples:

SET HOME="C:\Program Files\r\R-2.10\library" 
SET HOME=C:\Program Files\r\R-2.10\library

In that directory, create a text file named _netrc (note that it is underscore netrc, not dot netrclike it is on UNIX).

The following three lines must be included in the .netrc or _netrc file. They must be separated by either white space(spaces, tabs, or newlines) or commas:

machine <remote-instance-of-labkey-server>
login <user-email>
password <user-password>
One example would be:
machine mymachine.labkey.org
login user@labkey.org
password mypassword
Another example would be:
machine mymachine.labkey.org login user@labkey.org password mypassword

The _netrc file only deals with connections at the machine level and does not include a port or protocol designation.

例子:

$family = 'testftp';
$machine = Net::Netrc->lookup($family);
$user    = $$machine{'login'};
if ( !defined $user ) {
    print "Error, no entry .netrc for server $family\n";
}
$passwd = $$machine{'password'};
if ( !defined $passwd ) {
    print "Error, no password defined in .netrc for server $family\n";
}
print "user:$user passwd:$passwd\n";





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值