Problems with "diskutil" in shell scripts

Greetings,

I tend to use shell scripts in place of Finder commands because generally they seem to work a lot faster. One notable exception is the diskutil command. When trying to mount or umount (or eject) a disk it often takes a very long time or it doesn’t work at all. Running the commands from the terminal works fine, but running them from within Applescript does not. Has anyone encountered this before? Any insights as to why this happens?

Thanks,
WF