Busybox ash shell workaround for not working IFS on VMWare 4ESXi

Written by James McDonald

October 18, 2011

This doesn’t work

~ # cat fstest.sh
#!/bin/sh

ALLFILES=`ls -1 "/vmfs/volumes/4c371e81-0c463360-dfe3-001d091edb9f/ERP WinXP Client/"`

# I tried all sorts of things but this works with
# the vmware busybox (ash) shell

# this works you get correct field separation
IFS=$(echo -e '\n')

# but the for loop doesn't 
# chop the ALLFILES Variable up into \n  (newline) separated records.
for i in $ALLFILES; do
        echo "sep" 
        echo "$i"

done

# wrongo
~ # ./fstest.sh
sep
ERP WinXP Client-flat.vmdk
ERP WinXP Client.vmdk
ERP WinXP Client.vmsd
ERP WinXP Client.vmx
ERP WinXP Client.vmxf
Windows XP Professional 2.nvram

Work Around:


~ # cat fstest.sh
#!/bin/sh

LOCATE="/vmfs/volumes/4c371e81-0c463360-dfe3-001d091edb9f/QAD WinXP Client"

# not required
# IFS=$(echo -e '\n')

# safety check
cd "$LOCATE" || exit 1

for i in ./*;
do
    echo sep
    echo "$i"

done

~ # ./fstest.sh
sep
./ERP WinXP Client-309a615e.vswp
sep
./ERP WinXP Client-flat.vmdk
sep
./ERP WinXP Client.vmdk
sep
./ERP WinXP Client.vmsd
sep
./ERP WinXP Client.vmx
sep
./ERP WinXP Client.vmxf
sep
./Windows XP Professional 2.nvram


Disclaimer: This is posted here for my use. I am not responsible for any adverse happenings if you use this information. Check it! Check it again. Don’t use it on anything you really don’t want to destroy.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

You May Also Like…