Initial revision
This commit is contained in:
parent
188b15d9cb
commit
2bcb0db75e
97
clients/fstatcmd.c
Normal file
97
clients/fstatcmd.c
Normal file
|
|
@ -0,0 +1,97 @@
|
||||||
|
/*********************************************************************\
|
||||||
|
* Copyright (c) 2003 by Radim Kolar (hsn@cybermail.net) *
|
||||||
|
* Copyright (c) 1991 by Wen-King Su (wen-king@vlsi.cs.caltech.edu) *
|
||||||
|
* *
|
||||||
|
* You may copy or modify this file in any manner you wish, provided *
|
||||||
|
* that this notice is always included, and that you hold the author *
|
||||||
|
* harmless for any loss or damage resulting from the installation or *
|
||||||
|
* use of this software. *
|
||||||
|
\*********************************************************************/
|
||||||
|
|
||||||
|
#include "tweak.h"
|
||||||
|
#include "client_def.h"
|
||||||
|
#include "c_extern.h"
|
||||||
|
#include "bsd_extern.h"
|
||||||
|
#include "co_extern.h"
|
||||||
|
#ifdef STDC_HEADERS
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
#include "my-string.h"
|
||||||
|
|
||||||
|
static void stat_file PROTO1(const char *,fname)
|
||||||
|
{
|
||||||
|
struct stat sb;
|
||||||
|
struct tm *ftime;
|
||||||
|
char buf[35];
|
||||||
|
|
||||||
|
if(util_stat(fname,&sb))
|
||||||
|
{
|
||||||
|
printf("%s: stat error\n",fname);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
if(S_ISREG(sb.st_mode))
|
||||||
|
printf("File");
|
||||||
|
else
|
||||||
|
if(S_ISDIR(sb.st_mode))
|
||||||
|
printf("Directory");
|
||||||
|
|
||||||
|
ftime=localtime(&sb.st_mtime);
|
||||||
|
strftime(buf,35,"%Y-%m-%d %H:%M:%S",ftime);
|
||||||
|
#ifdef NATIVE_LARGEFILES
|
||||||
|
#define SFORM "%llu"
|
||||||
|
#else
|
||||||
|
#define SFORM "%lu"
|
||||||
|
#endif
|
||||||
|
printf(": %s Size: "SFORM" Time: %s\n",fname,sb.st_size,buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int main PROTO2(int, argc, char **, argv)
|
||||||
|
{
|
||||||
|
char n[1024];
|
||||||
|
int prompt;
|
||||||
|
char **av, *av2[2];
|
||||||
|
|
||||||
|
env_client();
|
||||||
|
|
||||||
|
if(argc>1)
|
||||||
|
{
|
||||||
|
for( optind=1; argc>optind ; optind++)
|
||||||
|
{
|
||||||
|
if(!(av = glob(argv[optind])))
|
||||||
|
{
|
||||||
|
av = av2;
|
||||||
|
av2[0] = argv[optind];
|
||||||
|
av2[1] = 0;
|
||||||
|
}
|
||||||
|
while(*av)
|
||||||
|
stat_file(*av++);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
prompt = isatty(0);
|
||||||
|
while(1) {
|
||||||
|
if(prompt) {
|
||||||
|
fputs("fstat: ",stdout);
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
if(!getsl(n,1024)) break;
|
||||||
|
if(!*n) break;
|
||||||
|
if(!(av = glob(n))) {
|
||||||
|
av = av2;
|
||||||
|
av2[0] = n;
|
||||||
|
av2[1] = 0;
|
||||||
|
}
|
||||||
|
while(*av)
|
||||||
|
stat_file(*av++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
client_done();
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
46
man/fstatcmd.1
Normal file
46
man/fstatcmd.1
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
.TH FSTAT 1 "23 September 2003" FSP
|
||||||
|
|
||||||
|
.SH NAME
|
||||||
|
fstatcmd, fstat displays information on remote files and directories
|
||||||
|
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.B fstatcmd
|
||||||
|
.I filename ...
|
||||||
|
.LP
|
||||||
|
.B fstat
|
||||||
|
.I filename ...
|
||||||
|
|
||||||
|
.SH DESCRIPTION
|
||||||
|
.LP
|
||||||
|
.B fstatcmd
|
||||||
|
will display the type (file or directory), name, size in bytes and
|
||||||
|
creation time of the given remote file. The time and date of creation will
|
||||||
|
be displayed in ISO format.
|
||||||
|
.LP
|
||||||
|
Since user's command shells generally cannot do the proper globbing for
|
||||||
|
this program, it is recommended that user defines a shell alias or
|
||||||
|
function to turn off command shell globbing before running this program.
|
||||||
|
.LP
|
||||||
|
.B csh
|
||||||
|
example:
|
||||||
|
.LP
|
||||||
|
.nf
|
||||||
|
alias fstat \e(set noglob\e; exec fstatcmd \e!\e*\e)
|
||||||
|
.fi
|
||||||
|
.LP
|
||||||
|
.B bash
|
||||||
|
example:
|
||||||
|
.LP
|
||||||
|
.nf
|
||||||
|
_fstat() { fstatcmd "$@" ;set +f;}
|
||||||
|
alias fstat='set -f;_fstat'
|
||||||
|
.fi
|
||||||
|
|
||||||
|
.SH ENVIRONMEN
|
||||||
|
See fsp_env(7) for list of used environment variables.
|
||||||
|
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
.PD
|
||||||
|
fcatcmd(1), fcdcmd(1), fgetcmd(1), fgrabcmd(1), flscmd(1), fmkdir(1),
|
||||||
|
fprocmd(1), fput(1), frmcmd(1), frmdircmd(1), fver(1), fducmd(1),
|
||||||
|
fhostcmd(1), fspd(1), fsp_prof(5), ffindcmd(1), fsp_env(7)
|
||||||
Loading…
Reference in New Issue
Block a user