No equivalent to strace on OS X and the mysterious left square bracket

Tonight a friend pointed out that there is a weird file in /bin on OS X. If you do ‘ls -la /bin’ you will most probably see a file called [. That is not a typo, the file has the left square bracket as a name.

Curious off the bat about what it does, I fired up strace and ran the [ file. Except strace doesn’t exist on OS X. strace lets you trace system calls and signals on a running file or a file that you run. Basically strace lets you watch what a file is doing. This can be very useful to solve mysterious problems.

So if you are on OS X and you need strace, you can always use ktrace instead. It works mostly the same it seems.

As for the /bin/[ file, it didn’t seem to do anything when I ran ‘ktrace /bin/[’

If I use otool to see what [ depends on it gives me:
[php][root scripts] otool -L /bin/[
/bin/[:
      /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
      /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.5)
[/php]

running strings - /bin/[ gives me long list:
[php][root scripts] strings - /bin/[
__PAGEZERO
__TEXT
__text
__TEXT
__cstring
__TEXT
__textcoal_nt
__TEXT
__DATA
__data
__DATA
__dyld
__DATA
__const
__DATA
__common
__DATA
__IMPORT
__pointers
__IMPORT
__jump_table
__IMPORT
__LINKEDIT
/usr/lib/dyld
/usr/lib/libgcc_s.1.dylib
/usr/lib/libSystem.B.dylib
,[^_]
[^_]
[^_]
,[^_]
,[^_]
?8!u
?8!uu?x
|[^_]
__dyld_make_delayed_module_initializer_calls
__dyld_mod_term_funcs
%s: %s
%s: out of range
%s: bad number
argument expected
closing paren expected
missing ]
unknown operand
_NXArgc
_NXArgv
___progname
__mh_execute_header
_catch_exception_raise
_catch_exception_raise_state
_catch_exception_raise_state_identity
_clock_alarm_reply
_do_mach_notify_dead_name
_do_mach_notify_no_senders
_do_mach_notify_port_deleted
_do_mach_notify_send_once
_do_seqnos_mach_notify_dead_name
_do_seqnos_mach_notify_no_senders
_do_seqnos_mach_notify_port_deleted
_do_seqnos_mach_notify_send_once
_environ
_receive_samples
__DefaultRuneLocale
___error
___keymgr_dwarf2_register_sections
___maskrune
__cthread_init_routine
_abort
_access
_atexit
_errno
_errx
_exit
_getegid
_geteuid
_isatty
_lstat
_mach_init_routine
_stat
_strcmp
_strtol
8__PAGEZERO
__TEXT
__text
__TEXT
__symbol_stub
__TEXT
__picsymbol_stub__TEXT
$__symbol_stub1
__TEXT
__cstring
__TEXT
__picsymbolstub1__TEXT
__DATA
__data
__DATA
__nl_symbol_ptr
__DATA
__la_symbol_ptr
__DATA
__dyld
__DATA
__const
__DATA
__common
__DATA
8__LINKEDIT

/usr/lib/dyld
/usr/lib/libgcc_s.1.dylib
/usr/lib/libSystem.B.dylib
#x|y
}“Kx@
9),?H
}“Kx
<8c,
@8c,
88c,
H8c,
L8c,
P8c-
- 9k-4
D8c-HH
x?B0
k0d}i
3x8`
X|BJ
__dyld_make_delayed_module_initializer_calls
__dyld_image_count
__dyld_get_image_name
__dyld_get_image_header
__dyld_NSLookupSymbolInImage
__dyld_NSAddressOfSymbol
libobjc
__objcInit
__dyld_mod_term_funcs
%s: %s
%s: out of range
%s: bad number
argument expected
closing paren expected
missing ]
unknown operand
_NXArgc
_NXArgv
___progname
__mh_execute_header
_catch_exception_raise
_catch_exception_raise_state
_catch_exception_raise_state_identity
_clock_alarm_reply
_do_mach_notify_dead_name
_do_mach_notify_no_senders
_do_mach_notify_port_deleted
_do_mach_notify_send_once
_do_seqnos_mach_notify_dead_name
_do_seqnos_mach_notify_no_senders
_do_seqnos_mach_notify_port_deleted
_do_seqnos_mach_notify_send_once
_environ
_receive_samples
__DefaultRuneLocale
___error
___keymgr_dwarf2_register_sections
___maskrune
__cthread_init_routine
_abort
_access
_atexit
_errno
_errx$LDBL128
_exit
_getegid
_geteuid
_isatty
_lstat
_mach_init_routine
_stat
_strcmp
_strtol
[/php]

So, I have no more time to investigate further right now, and Google shows nothing useful. If anyone has an idea of what the mysterious [ binary does, please let me know. Thanks!

Use MacFUSE sshfs to mount an SSH session on your desktop

A buddy pointed me to MacFUSE from Google today. This is a very cool little app headed up by Amit Singh at Google Inc. Note that the little how-to I am going to show you here is based on the fact that I am using OS X.

MacFUSE implements a mechanism that makes it possible to implement a fully functional file system in a user-space program on Mac OS X (10.4 and above). It aims to be API-compliant with the FUSE (File-system in USErspace) mechanism that originated on Linux. Therefore, many existing FUSE file systems become readily usable on Mac OS X. The core of MacFUSE is in a dynamically loadable kernel extension.

Really quickly it means I can mount an SSH session on my desktop as a folder. For a fast little how-to from the parts I collected from Google, scroll on down past the Google Video.

If you want to hear what MacFuse is about from the creator Amit Singh, checkout this Google Video:


This install will require a reboot of your machine.

Okay, first off, let’s download MacFUSE from Google here.. Before installing MacFUSE you will need to add the /usr/local/bin path to your environment for this to work properly. Edit your ~/.bashrc file and add this line:
PATH=$PATH:/usr/local/bin

then at the prompt enter this and hit return:
source ~/.bashrc

So now you have the path you need in your bash environment, we can go ahead and install MacFUSE. Mount the image you downloaded from Google and install the package in the disk mount and reboot your machine.

Once you machine has rebooted, and you have logged in, hop into Terminal and enter the following to mount an SSH session on your desktop:
sshfs username@domainname:/path/to/mount /local/mount/point -oping_diskarb,volname=your_volume_name

Substitute of course, username, domainname, path to mount, local mount point and your_volume_name for your own information. Hit enter and if all went correctly, you should be asked for the password to the SSH login. Enter the password, hit enter, and again, if all went well, you should now have a new File System mounted on your desktop.

It will work just like a normal folder on your mac, copy files to and from the folder using drag and drop, and the Finder undo even works.

Once you have finished you can unmount the drive easily by ejecting it using OS X’s normal disk ejected method, or you can use:
umount /local/mount/point

Notes:

  • My buddy said using the Finder eject caused some weirdness on his machine.
  • Here is the link to the MacFUSE wiki for more information.
  • As usual, and even more so than usual since this software is Beta, you are doing everything at your own risk. Don’t blame me if you machine suddenly goes weird. You’ve been warned.

 

Page 2 of 2 pages  < 1 2