Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Mac > BOOK: Beginning Mac OS X Programming
|
BOOK: Beginning Mac OS X Programming
This is the forum to discuss the Wrox book Beginning Mac OS X Programming by Michael Trent, Drew McCormack; ISBN: 9780764573996
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Mac OS X Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 25th, 2006, 11:54 AM
Registered User
 
Join Date: Apr 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default bug in exercise 2 in chapter 1?

Exercise 2 in chapter 1 states that the commands:

man -k "copy file"

and

apropos "copy file"

return equivalent results. I found this not to be the case. I've tried this on two Macs, both running OS 10.4.6

I've copied the results from my terminal below. When I use the command:

apropos "copy file" I get a short response as follows:

================================================== ====================
bluewater:~ swartout$ apropos "copy file"
CpMac(1), /Developer/Tools/CpMac(1) - copy files preserving metadata and forks
File::Copy(3pm) - Copy files or filehandles
cp(1) - copy files
cpio(1) - copy file archives in and out
ditto(1) - copy files and directories to a destination directory
bluewater:~ swartout$
================================================== ===================
But when I use the command

man -k "copy file"

I get a much longer response, which I have truncated below:
================================================== ====================
bluewater:~ swartout$ man -k "copy file"
CpMac(1), /Developer/Tools/CpMac(1) - copy files preserving metadata and forks
File::Copy(3pm) - Copy files or filehandles
FileSystem(3tcl), Tcl_FSRegister(3tcl), Tcl_FSUnregister(3tcl), Tcl_FSData(3tcl), Tcl_FSMountsChanged(3tcl), Tcl_FSGetFileSystemForPath(3tcl), Tcl_FSGetPathType(3tcl), Tcl_FSCopyFile(3tcl), Tcl_FSCopyDirectory(3tcl), Tcl_FSCreateDirectory(3tcl), Tcl_FSDeleteFile(3tcl), Tcl_FSRemoveDirectory(3tcl), Tcl_FSRenameFile(3tcl), Tcl_FSListVolumes(3tcl), Tcl_FSEvalFile(3tcl), Tcl_FSLoadFile(3tcl), Tcl_FSMatchInDirectory(3tcl), Tcl_FSLink(3tcl), Tcl_FSLstat(3tcl), Tcl_FSUtime(3tcl), Tcl_FSFileAttrsGet(3tcl), Tcl_FSFileAttrsSet(3tcl), Tcl_FSFileAttrStrings(3tcl), Tcl_FSStat(3tcl), Tcl_FSAccess(3tcl), Tcl_FSOpenFileChannel(3tcl), Tcl_FSGetCwd(3tcl), Tcl_FSChdir(3tcl), Tcl_FSPathSeparator(3tcl), Tcl_FSJoinPath(3tcl), Tcl_FSSplitPath(3tcl), Tcl_FSEqualPaths(3tcl), Tcl_FSGetNormalizedPath(3tcl), Tcl_FSJoinToPath(3tcl), Tcl_FSConvertToPathType(3tcl), Tcl_FSGetInternalRep(3tcl), Tcl_FSGetTranslatedPath(3tcl), Tcl_FSGetTranslatedStringPath(3tcl), Tcl_FSNewNativePath(3tcl), Tcl_FSGetNativePath(3tcl), Tcl_FSFileSystemInfo(3tcl), Tcl_AllocStatBuf(3tcl) - procedures to interact with any filesystem
GFDL(1) - The GNU Free Documentation License Version 1.1, March 2000 Copyright t (co n (c) 2000 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed
acl_copy_entry(3) - copy an ACL entry to another ACL entry
asr(8) - Apple Software Restore; copy volumes (e.g. from disk images)
bcmp(3), bcopy(3), bzero(3), memccpy(3), memchr(3), memcmp(3), memcpy(3), memmove(3), memset(3) - byte string operations
bcopy(3) - copy byte string
copy(9), copyin(9), copyout(9), copystr(9), copyinstr(9) - kernel copy functions
copysign(3) - changes the sign of x to that of y
cp(1) - copy files
cpio(1) - copy file archives in and out
dd(1) - convert and copy a file
ditto(1) - copy files and directories to a destination directory
fcopy(ntcl) - Copy data from one channel to another
memccpy(3) - copy string until character found
memcpy(3) - copy memory area
memmove(3) - copy byte string
netsnmp_library(3), The Net-SNMP library(3) - "Modules" +1c -1c "groupasn1 parsing and datatype manipulation routines." -1c "groupA generic callback mechanism" -1c "groupgeneric linked-list data handling with a string as a key." -1c "groupstorage space for defaults" "The purpose of the default storage is three-fold:. " +1c -1c "groupmib parsing and datatype manipulation routines." -1c "groupStore and retrieve data referenced by an OID." "This is essentially a way of storing data associated with a given OID. " +1c -1c "groupparsing various configuration files at run time" "The read_config related functions are a fairly extensible system of parsing various configuration files at the run time. " +1c -1c "groupgeneric library based alarm timers for various parts of an application" -1c "groupvarious PDU processing routines" -1c "groupgeneric logging for net-snmp" -1c "groupMemory Utility Routines" -1c "Data Structures" +1c -1c "struct snmp_internal_session" -1c "struct session_list" -1c "Defines" +1c -1c "#define MIN(a, b) (((a) < (b)) ? (a) : (b))" -1c "#define MIB_CLIENTS_ARE_EVIL 1" -1c "#define _init_agent_callback_transport()" -1c "#define SNMP_NEED_REQUEST_LIST" -1c "#define timercmp(tvp, uvp, cmp)" -1c "#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0" -1c "#define MAX_PACKET_LENGTH (0x7fffffff)" -1c "#define NETSNMP_STREAM_QUEUE_LEN 5" -1c "#define BSD4_2" -1c "#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */" -1c "#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))" -1c "#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))" -1c "#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))" -1c "#define FD_ZERO(p) memset((p), 0, sizeof(*(p)))" -1c "#define DEFAULT_COMMUNITY 'public'" -1c "#define DEFAULT_RETRIES 5" -1c "#define DEFAULT_TIMEOUT 1000000L" -1c "#define DEFAULT_REMPORT SNMP_PORT" -1c "#define DEFAULT_ENTERPRISE default_enterprise" -1c "#define DEFAULT_TIME 0" -1c "#define MAXIMUM_PACKET_SIZE 0x7fffffff" -1c "#define DEBUGPRINTPDUTYPE(token, type)" -1c "#define ERROR_STAT_LENGTH 11" -1c "Typedefs" +1c -1c "typedef long fd_mask" -1c "Functions" +1c -1c "int init_agent (const char *app)" "Initialize the agent. " -1c "void shutdown_agent (void)" -1c "int snmp_build (u_char **pkt, size_t *pkt_len, size_t *offset, netsnmp_session *pss, netsnmp_pdu *pdu)" -1c "int snmp_get_errno (void)" -1c "void snmp_synch_reset (netsnmp_session *notused)" -1c "void snmp_synch_setup (netsnmp_session *notused)" -1c "const char * strerror (int err)" -1c "long snmp_get_next_reqid (void)" -1c "long snmp_get_next_msgid (void)" -1c "long snmp_get_next_sessid (void)" -1c "long snmp_get_next_transid (void)" -1c "void snmp_perror (const char *prog_string)" -1c "void snmp_set_detail (const char *detail_string)" -1c "const char * snmp_api_errstring (int snmp_errnumber)" -1c "void snmp_error (netsnmp_session *psess, int *p_errno, int *p_snmp_errno, char **p_str)" -1c "void snmp_sess_error (void *sessp, int *p_errno, int *p_snmp_errno, char **p_str)" -1c "void netsnmp_sess_log_error (int priority, const char *prog_string, netsnmp_session *ss)" -1c "void snmp_sess_perror (const char *prog_string, netsnmp_session *ss)" -1c "void snmp_sess_init (netsnmp_session *session)" -1c "void init_snmp_enums (void)" -1c "void init_snmp (const char *type)" "Calls the functions to do config file loading and mib module parsing in the correct order. " -1c "void snmp_store (const char *type)" -1c "void snmp_shutdown (const char *type)" "Shuts down the application, saving any needed persistent storage, and appropriate clean up. " -1c "netsnmp_session * snmp_open (netsnmp_session *session)" -1c "netsnmp_session * snmp_open_ex (netsnmp_session *session, int(*fpre_parse)(netsnmp_session *, netsnmp_transport *, void *, int), int(*fparse)(netsnmp_session *, netsnmp_pdu *, u_char *, size_t), int(*fpost_parse)(netsnmp_session *, netsnmp_pdu *, int), int(*fbuild)(netsnmp_session *, netsnmp_pdu *, u_char *, size_t *), int(*frbuild)(netsnmp_session *, netsnmp_pdu *, u_char **, size_t *, size_t *), int(*fcheck)(u_char *, size_t))" -1c "int snmpv3_engineID_probe (struct session_list *slp, netsnmp_session *in_session)" -1c "netsnmp_session * snmp_add (netsnmp_session *in_session, netsnmp_transport *transport, int(*fpre_parse)(netsnmp_session *, netsnmp_transport *, void *, int), int(*fpost_parse)(netsnmp_session *, netsnmp_pdu *, int))" -1c "netsnmp_session * snmp_add_full (netsnmp_session *in_session, netsnmp_transport *transport, int(*fpre_parse)(netsnmp_session *, netsnmp_transport *, void *, int), int(*fparse)(netsnmp_session *, netsnmp_pdu *, u_char *, size_t), int(*fpost_parse)(netsnmp_session *, netsnmp_pdu *, int), int(*fbuild)(netsnmp_session *, netsnmp_pdu *, u_char *, size_t *), int(*frbuild)(netsnmp_session *, netsnmp_pdu *, u_char **, size_t *, size_t *), int(*fcheck)(u_char *, size_t), netsnmp_pdu *(*fcreate_pdu)(netsnmp_transport *, void *, size_t))" -1c "void * snmp_sess_add_ex (netsnmp_session *in_session, netsnmp_transport *transport, int(*fpre_parse)(netsnmp_session *, netsnmp_transport *, void *, int), int(*fparse)(netsnmp_session *, netsnmp_pdu *, u_char *, size_t), int(*fpost_parse)(netsnmp_session *, netsnmp_pdu *, int), int(*fbuild)(netsnmp_session *, netsnmp_pdu *, u_char *, size_t *), int(*frbuild)(netsnmp_session *, netsnmp_pdu *, u_char **, size_t *, size_t *), int(*fcheck)(u_char *, size_t), netsnmp_pdu *(*fcreate_pdu)(netsnmp_transport *, void *, size_t))" -1c "void * snmp_sess_add (netsnmp_session *in_session, netsnmp_transport *transport, int(*fpre_parse)(netsnmp_session *, netsnmp_transport *, void *, int), int(*fpost_parse)(netsnmp_session *, netsnmp_pdu *, int))" -1c "void * snmp_sess_open (netsnmp_session *pss)" -1c "int create_user_from_session (netsnmp_session *session)" -1c "int snmp_sess_close (void *sessp)" -1c "int snmp_close (netsnmp_session *session)" -1c "int snmp_close_sessions (void)" -1c "int snmpv3_packet_build (netsnmp_session *session, netsnmp_pdu *pdu, u_char *packet, size_t *out_length, u_char *pdu_data, size_t pdu_data_len)" -1c "u_char * snmp_pdu_build (netsnmp_pdu *pdu, u_char *cp, size_t *out_length)" -1c "int snmpv3_parse (netsnmp_pdu *pdu, u_char *data, size_t *length, u_char **after_header, netsnmp_session *sess)" -1c "int snmpv3_make_report (netsnmp_pdu *pdu, int error)" -1c "int snmpv3_get_report_type (netsnmp_pdu *pdu)" -1c "int snmp_pdu_parse (netsnmp_pdu *pdu, u_char *data, size_t *length)" -1c "u_char * snmpv3_scopedPDU_parse (netsnmp_pdu *pdu, u_char *cp, size_t *length)" -1c "int snmp_send (netsnmp_session *session, netsnmp_pdu *pdu)" -1c "int snmp_sess_send (void *sessp, netsnmp_pdu *pdu)" -1c "int snmp_async_send (netsnmp_session *session, netsnmp_pdu *pdu, snmp_callback callback, void *cb_data)" -1c "int snmp_sess_async_send (void *sessp, netsnmp_pdu *pdu, snmp_callback callback, void *cb_data)" -1c "void snmp_free_var (netsnmp_variable_list *var)" -1c "void snmp_free_varbind (netsnmp_variable_list *var)" -1c "void snmp_free_pdu (netsnmp_pdu *pdu)" -1c "netsnmp_pdu * snmp_create_sess_pdu (netsnmp_transport *transport, void *opaque, size_t olength)" -1c "void snmp_read (fd_set *fdset)" -1c "int _sess_read (void *sessp, fd_set *fdset)" -1c "int snmp_sess_read (void *sessp, fd_set *fdset)" -1c "int snmp_select_info (int *numfds, fd_set *fdset, struct timeval *timeout, int *block)" -1c "int snmp_sess_select_info (void *sessp, int *numfds, fd_set *fdset, struct timeval *timeout, int *block)" -1c "void snmp_timeout (void)" -1c "void snmp_sess_timeout (void *sessp)" -1c "int snmp_oid_ncompare (const oid *in_name1, size_t len1, const oid *in_name2, size_t len2, size_t max_len)" -1c "int snmp_oid_compare (const oid *in_name1, size_t len1, const oid *in_name2, size_t len2)" "lexicographical compare two object identifiers. " -1c "int snmp_oidtree_compare (const oid *in_name1, size_t len1, const oid *in_name2, size_t len2)" "Compares 2 OIDs to determine if they are equal up until the shortest length. " -1c "int netsnmp_oid_equals (const oid *in_name1, size_t len1, const oid *in_name2, size_t len2)" "Compares 2 OIDs to determine if they are exactly equal. " -1c "int netsnmp_oid_is_subtree (const oid *in_name1, size_t len1, const oid *in_name2, size_t len2)" "Identical to netsnmp_oid_equals, except only the length up to len1 is compared. " -1c "int netsnmp_oid_find_prefix (const oid *in_name1, size_t len1, const oid *in_name2, size_t len2)" "Given two OIDs, determine the common prefix to them both. " -1c "netsnmp_variable_list * snmp_pdu_add_variable (netsnmp_pdu *pdu, const oid *name, size_t name_length, u_char type, const u_char *value, size_t len)" -1c "netsnmp_variable_list * snmp_varlist_add_variable (netsnmp_variable_list **varlist, const oid *name, size_t name_length, u_char type, const u_char *value, size_t len)" -1c "int snmp_add_var (netsnmp_pdu *pdu, const oid *name, size_t name_length, char type, const char *value)" -1c "void * snmp_sess_pointer (netsnmp_session *session)" -1c "netsnmp_session * snmp_sess_session (void *sessp)" -1c "netsnmp_transport * snmp_sess_transport (void *sessp)" -1c "void snmp_sess_transport_set (void *sp, netsnmp_transport *t)" -1c "oid * snmp_duplicate_objid (const oid *objToCopy, size_t objToCopyLen)" -1c "u_int snmp_increment_statistic (int which)" -1c "u_int snmp_increment_statistic_by (int which, int count)" -1c "u_int snmp_get_statistic (int which)" -1c "void snmp_init_statistics (void)" -1c "Variables" +1c -1c "netsnmp_subtree * subtrees" -1c "long long_return" -1c "u_char return_buf [258]" -1c "timeval starttime" -1c "int callback_master_num = -1" -1c "oid nullOid [] = { 0, 0 }" -1c "int nullOidLen = sizeof(nullOid)" -1c "session_list * Sessions = NULL" -1c "int snmp_errno = 0" -1c "long long_return" -1c "u_char return_buf []" -1c "oid nullOid []" -1c "int nullOidLen" -1c
overlay(3x), overwrite(3x), copywin(3x) - overlay and manipulate overlapped curses windows
pax(1) - read and write file archives and copy directory hierarchies
pbcopy(1), pbpaste(1) - provide copying and pasting to the pasteboard (the Clipboard) from command line
rcp(1) - remote file copy
scp(1) - secure copy (remote file copy program)
================================================== =====================
The results don't seem to be equivalent to me....what am I missing?

Thanks for your help.
-Bill

 
Old May 28th, 2006, 07:29 AM
Authorized User
 
Join Date: Aug 2005
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Easy. just give one argument to man -k and the result will be the same than apropos. To see that, type Cmd-N to get two shell windows and in the first, type man-k copy, and in the second, type apropos copy. This time, you will get no difference between the results.

FJ
 
Old June 3rd, 2006, 01:08 PM
Wrox Author
 
Join Date: Nov 2005
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Huh. That wasn't the case when I wrote it. It used to match exactly.

The point of this exercise is really to become familiar with using the apropos and man commands. It's not important that the output matches exactly. What is important is that you learn how to use these tools to find information you might need.

Sorry it was a little confusing.

 
Old June 5th, 2006, 12:39 PM
Registered User
 
Join Date: Apr 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks --- just wanted to be sure I wasn't missing something...



Quote:
quote:Originally posted by mtrent
 Huh. That wasn't the case when I wrote it. It used to match exactly.

The point of this exercise is really to become familiar with using the apropos and man commands. It's not important that the output matches exactly. What is important is that you learn how to use these tools to find information you might need.

Sorry it was a little confusing.

 
Old May 6th, 2007, 09:40 PM
Registered User
 
Join Date: May 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello all, I have run into the very same problem that Swartout ran into.

I understand that the point of this exercise is to become familiar with sending requests to
a shell, but why would a shell respond correctly to apropos "copy file" but fail to respond to man -k "copy file" in the same way when the two are interchangeable.

I know I can just use apropos instead of man -k but this glitch is bugging me because if the shell is not responding to the -k flag in the way that it should then what else will it have problems with.

I was wondering if we were all using bash, but since it is the default I guess we are.

I think maybe I am worrying too much over this.

man -A "ndrew"





Similar Threads
Thread Thread Starter Forum Replies Last Post
chapter 3 exercise 4 walkamongus BOOK: Beginning JavaScript 3rd Ed. ISBN: 978-0-470-05151-1 0 September 10th, 2007 09:34 PM
Chapter 3 - Exercise 3 AndyN BOOK: Beginning Cryptography with Java 3 August 16th, 2006 03:09 PM
chapter 9 exercise michaelcode BOOK: Beginning ASP.NET 1.0 1 April 9th, 2006 03:56 PM
Chapter 4, Exercise 3 DRAYKKO BOOK: Beginning Java 2 3 July 9th, 2004 02:34 PM
Chapter 8, Exercise 4 cjo BOOK: Beginning ASP.NET 1.0 0 November 3rd, 2003 02:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.