/* used by parser to parse filenames, e.g. mach:file */
/* netcp - copy with remote machines */
register struct fd
*ff
, *tf
, ffile
, tfile
;
char tomachstr
[BUFSIZ
], rcmd
[BUFSIZ
], acmd
[BUFSIZ
], *sn
;
while(argv
[0][0] == '-'){
case 'b': status
.nonotify
++; break;
case 'f': status
.force
++; break;
case 'l': harg(status
.login
,&argc
,&argv
); break;
case 'n': status
.nowrite
++; break;
case 'p': harg(status
.mpasswd
,&argc
,&argv
); break;
case 'q': status
.quiet
++; break;
default: fprintf(stderr
,"Unknown option %s\n",argv
[0]);
sprintf(rcmd
,"netcp %s %s",argv
[0],argv
[1]);
if(ff
->mach
== 0 || tf
->mach
== 0){
fprintf(stderr
,"Unknown machine\n");
if(ff
->fn
[0] == 0 || tf
->fn
[0] == 0){
fprintf(stderr
,"Must specify both file names\n");
sprintf(tomachstr
,"-m%c",tf
->mach
);
if(ff
->mach
== local
&& tf
->mach
== local
){
fprintf(stderr
,"Error: both files are on this machine\n");
else if(ff
->mach
== local
)
kexecl(netcmd
,"net",tomachstr
, "-o",tf
->fn
,"-s",ff
->fn
,
else if(tf
->mach
== local
){
kexecl(netcmd
,"net",tomachstr
, "-r",tf
->fn
,"-i",ff
->fn
,
else if(tf
->mach
== ff
->mach
)
kexecl(netcmd
,"net",tomachstr
,"-c",rcmd
,"cp",ff
->fn
,tf
->fn
,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){
fprintf(stderr
,"Unknown user\n");
strcpy(status
.localname
,sn
);
/* 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 */
remote
= tomachstr
[2] = ff
->mach
;
status
.login
[0] = status
.mpasswd
[0] = 0;
mexecl(netcmd
,"net",tomachstr
,"-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;
if(colon
){ /* name specified */
if(c0
== '/' && c1
!= '/' && islower(c1
))
if(c2
== '/')f
->mach
= 'y'; /* Cory name */
else if(c3
== '/')f
->mach
= c1
; /* CC name */
f
->fn
= calloc(strlen(file
)+1,1);
/* check for bad chars in file name */
if(c
== ' ' || c
== '\n' || c
== '\r' || c
== '\t' || c
== '\b')
err("Invalid character '%c'\n",c
);