Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rutgers!sri-unix!sri-spam!ames!amdcad!amd!intelca!oliveb!felix!ccicpg!turnkey!conexch!root From: root@conexch.UUCP (Larry Dighera) Newsgroups: comp.sources.wanted Subject: Re: "cpmod" Copy Modes program wanted Message-ID: <127@conexch.UUCP> Date: Sat, 15-Aug-87 12:04:03 EDT Article-I.D.: conexch.127 Posted: Sat Aug 15 12:04:03 1987 Date-Received: Sat, 22-Aug-87 10:45:14 EDT References: <1092@ttidca.TTI.COM> Reply-To: root@conexch.UUCP (Larry Dighera) Distribution: na Organization: The Consultants' Exchange, Orange County, CA. (714) 842-6348 Public Access Lines: 94 In article <1092@ttidca.TTI.COM> sa@ttidca.TTI.COM (Steve Alter) writes: >We could really use a "cpmod" program to copy modes/ownerships/times >from one existing file to other existing files. I envision the >syntax like: > > cpmod [-m] [-o] [-t] file another-file ... > >This would copy modes (unless -m is given), ownerships (unless -o is >given) and times (unless -t is given) from the first file to all of >the other files. Note that copying of times is not possible if any >destination file is a directory, but no error message should be >produced in that case. If all three options are given then an error >message should be produced saying that there is no work left to do. >Citicorp/TTI, Santa Monica CA (213) 452-9191 x2541 Your proposal for a new command strikes a resonant chord with me. I too have been longing for a way to specify modes and ownerships with a single cp or mv command. An associate wrote the following "first attempt" at a program that combines chmod, chown, chgrp. ----------------------------- C U T H E R E --------------------------- /* * Chall ( Change all ) is a poor attempt to combined chown, chgrp, and * chmod into one program. The usage of the program is as follows: * chall file_name owner [group [ permissions ]] * * Please note that group and permissions are optional. * If you wish to leave one of the fields as they already exist, you can * enter a - ( minus) in that field and that entry will be skipped. An * example is as follows: chall foo - group 777 * The above entry will change the group and permissions only! * * Written without any glory by Sanford Zelkovitz * */ #include #define OWNER "chown " #define GROUP "chgrp " #define PERMS "chmod " char buffer[99]; main(argc, argv) int argc; char *argv[]; { if(argc < 3) { (void)fprintf(stderr, "\nUsage: chall filename owner [group perms]\n"); exit (1); } if(argv[2][0] == '-')goto l1; strcpy(buffer, OWNER); strcat(buffer, argv[2]); strcat(buffer, " "); strcat(buffer, argv[1]); (void)system(buffer); l1: if(argc == 3)return; if(argv[3][0] == '-')goto l2; strcpy(buffer, GROUP); strcat(buffer, argv[3]); strcat(buffer, " "); strcat(buffer, argv[1]); (void)system(buffer); l2: if(argc == 4)return; if(argv[4][0] == '-')return; strcpy(buffer, PERMS); strcat(buffer, argv[4]); strcat(buffer, " "); strcat(buffer, argv[1]); (void)system(buffer); } ----------------------------- C U T H E R E --------------------------- Perhaps this will inspire one of our resident gurus into action. Here is what I envision as a single command to perform the duties of cp, chmod, chown, chgrp, and touch. cpx [-m xxxx] [-o owner] [-g group] [-t MMDDYYHHMM] source-file dest Where each -option changes the destination file's mode, ownership, group, and/or time to that option's argument. Ideally, the full syntax of chmod would be supported. A similarly smart mvx program would also be useful. I suppose that the "proper" way to implement this type of functionality in a command and still remain safely within the "philosophy of Un*x" would be to write a suitable shell script :-). Best Regards, Larry Dighera -- USMAIL: The Consultants' Exchange, PO Box 12100, Santa Ana, CA 92712 (714) 842-6348: IBM-PC BBS (N81); (714) 842-5851: Xenix guest account (E71) UUCP: ...!ucbvax!ucivax!mickey!conexch!root || ...!trwb!ucla-an!conexch!root UUCP: conexch Any ACU 2400 17148425851 ogin:-""-ogin:-""-ogin: nuucp