static char sccsid
[] = "@(#)netcp.c 4.1 (Berkeley) %G%";
static char *netcp_sid
= "@(#)netcp.c 1.2";
/* netcp - copy with remote machines */
char rcmd
[BUFSIZ
], acmd
[BUFSIZ
], *sn
;
char mchto
, mchfrom
, sfnto
[FNS
], sfnfrom
[FNS
];
while(argv
[0][0] == '-'){
case 'b': status
.nonotify
++; break;
case 'f': status
.force
++; break;
case 'l': harg(status
.login
); break;
case 'n': status
.nowrite
++; break;
case 'p': harg(status
.mpasswd
); break;
case 'q': status
.quiet
++; break;
default: fprintf(stderr
,"Unknown option %s\n",argv
[0]);
sprintf(rcmd
,"netcp %s %s",argv
[0],argv
[1]);
mchfrom
= analfile(sfnfrom
,argv
[0]);
mchto
= analfile(sfnto
,argv
[1]);
if(mchfrom
== 0 || mchto
== 0){
fprintf(stderr
,"Unknown machine\n");
if(sfnfrom
[0] == 0 || sfnto
[0] == 0){
fprintf(stderr
,"Must specify both file names\n");
if(mchfrom
== local
&& mchto
== local
){
fprintf(stderr
,"Error: both files are on this machine\n");
else if(mchfrom
== local
)
kexecl(netcmd
,"net","-m",longname(mchto
), "-o",sfnto
,"-s",sfnfrom
,
kexecl(netcmd
,"net","-m",longname(mchfrom
), "-r",sfnto
,"-i",sfnfrom
,
else if(mchto
== mchfrom
)
kexecl(netcmd
,"net","-m",longname(mchto
),"-c",rcmd
,"cp",sfnfrom
,sfnto
,0);
/* experimental - still needs debugging */
"Experimental - Machines normally must be the same\n");
/* collect info on the "To Machine" */
/* get status.login and passwd from .netrc if poss. */
if(status
.login
[0] == 0 || status
.mpasswd
[0] == 0){
sn
= SnFromUid(getuid());
fprintf(stderr
,"Unknown user\n");
strcpy(status
.localname
,sn
);
envloginpasswd(remote
,status
.login
,status
.mpasswd
);
/* should use -q option */
sprintf(acmd
,"%s -l %s -p %s %s %s",
NETCPCMD
,status
.login
,status
.mpasswd
,argv
[0],argv
[1]);
/* send the netcp command to the "From" machine */
status
.login
[0] = status
.mpasswd
[0] = 0;
mexecl(netcmd
,"net","-m",longname(mchfrom
),"-c",rcmd
,acmd
,0);
fprintf(stderr
,"Network is down\n");
printf("Usage: netcp [-l ...] [-p ...] [-f] [-n] fromfile tofile\n");
char work
[FNS
], *s
, c0
,c1
,c2
,c3
,c
,colon
=0,mch
;
if(colon
){ /* name specified */
if(c0
== '/' && c1
!= '/' && islower(c1
))
if(c3
== '/')mch
= c1
; /* CC name */
/* check for bad chars in file name */
if(c
== ' ' || c
== '\n' || c
== '\r' || c
== '\t' || c
== '\b')
err("Invalid character '%c'\n",c
);