========PERL VERSION================ #!/usr/bin/perl # By: h0e $editor ="/usr/bin/vi"; $file = shift or die "usage: $0 file\n"; ($atime, $mtime) = (stat($file))[8,9]; system($ENV{EDITOR} || "$editor", $file); utime($atime, $mtime, $file) or die "Cant set $file original times: $!\n"; =======END PERL VERSION====================== ========C VERSION===================== /* By h0e */ #include #include #include #include #include #include #include #include static void usage(char *me) { fprintf(stderr, "Usage: %s -c file\n", me); exit(EXIT_FAILURE); } int main(int argc, char *argv[]) { int opt; char filename[FILENAME_MAX]; char command[FILENAME_MAX]; char *tmp; static struct timeval tv[2]; static struct stat sb; filename[0] = 0; command[0] = 0; while ((opt = getopt(argc, argv, "c:h")) != EOF) { switch (opt) { case 'c': strncpy(command, optarg, sizeof(command)); break; case 'h': default: usage(argv[0]); } } if (argc == optind) usage(argv[0]); if (!command[0]) { if ((tmp = getenv("EDITOR")) == NULL) usage(argv[0]); strncpy(command, tmp, sizeof(command)); } strncpy(filename, argv[optind], sizeof(filename)); if (stat(filename, &sb) == -1) { perror(filename); exit(errno); } strncat(command, " ", sizeof(command)); strncat(command, filename, sizeof(command)); tv[0].tv_sec = sb.st_atime; tv[1].tv_sec = sb.st_mtime; if (system(command) == -1) { fprintf(stderr, "problem excuting '%s'\n", command); exit(EXIT_FAILURE); } if (utimes(filename, tv) == -1) { perror("utimes()"); exit(errno); } exit(EXIT_SUCCESS); } ============END C VERSION====================