The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


Grips::Gripsrc - OO interface to users gripsrc file


    use Grips::Gripsrc;

    $mach = Grips::Gripsrc->lookup('');
    $id = $mach->id;
    ($id, $user, $pwd) = $mach->iup;


Grips::Gripsrc is a class implementing a simple interface to the .gripsrc file used as by the ftp program.

Grips::Gripsrc also implements security checks just like the ftp program, these checks are, first that the .gripsrc file must be owned by the id and second the ownership permissions should be such that only the owner has read and write access. If these conditions are not met then a warning is output and the .gripsrc file is not read.

THE .gripsrc FILE

The .gripsrc file contains id and initialization information used by the auto-login process. It resides in the user's home directory. The following tokens are recognized; they may be separated by spaces, tabs, or new-lines:

host name

Identify a remote host name. The auto-login process searches the .gripsrc file for a host token that matches the remote host specified. Once a match is made, the subsequent .gripsrc tokens are processed, stopping when the end of file is reached or an- other host or a default token is encountered.


This is the same as host name except that default matches any name. There can be only one default token, and it must be after all host tokens. This is normally used as:

    default id anonymous user id@site

thereby giving the user automatic anonymous login to hosts not specified in .gripsrc.

id name

Identify a id on the remote host. If this token is present, the auto-login process will initiate a login using the specified name.

user string

Supply a password. If this token is present, the auto-login process will supply the specified string if the remote server requires a password as part of the login process.

pwd string

Supply an additional password. If this token is present, the auto-login process will supply the specified string if the remote server requires an additional password.

macdef name

Define a macro. Grips::Gripsrc only parses this field to be compatible with ftp.


The constructor for a Grips::Gripsrc object is not called new as it does not really create a new object. But instead is called lookup as this is essentially what it does.

lookup ( HOST [, ID ])

Lookup and return a reference to the entry for HOST. If ID is given then the entry returned will have the given login. If ID is not given then the first entry in the .gripsrc file for HOST will be returned.

If a matching entry cannot be found, and a default entry exists, then a reference to the default entry is returned.


id ()

Return the id for the gripsrc entry

user ()

Return the user code for the gripsrc entry

pwd ()

Return the pwd information for the gripsrc entry

iup ()

Return a list of id, user and pwd information fir the gripsrc entry


Tarek Ahmed <>


Grips::Gripsrc Grips::Cmd


Copyright (c) 2002 DIMDI. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Confession: I took most of the stuff of Net::Netrc and converted it to this module. Thanks, Graham Barr :-)

$Id:,v 1.2 2003-02-04 12:19:08 ahmed Exp $