I have this Script that simply mount the attached External drive and write their mounted path in a text file. Though when I run this script from terminal in tinyCOre it works fine. Following is the Code I am using to execute the script, I am using this code throughout my application for mounting and other purposes but non of them have writing to do.
Code:
Process p = Runtime.getRuntime().exec(" sh /home/abc/mnt-ddc.sh");
p.waitFor();
I even tried taking the script as array but no help. Quick help will be appreciated. Thanks.
UPDATE WHen the script is executed from java, nothing happens, no exception thrown, no nothing. I tried all the ways answered below none working.
mnt-ddc.sh
#!/bin/sh
blkid -s LABEL | grep ddc- > ddc.txt # Get DDC device name and label and write to ddc.txt
perl -pi -e 's/ LABEL="//g' ddc.txt # Remove text "ddc- from ddc.txt
#perl -pi -e 's/ LABEL="ddc-//g' ddc.txt # Remove text "ddc- from ddc.txt
perl -pi -e 's/" //g' ddc.txt # Remove left over text " from ddc.txt
while IFS=: read dev label # start loop and read device name to $dev and LABEL to $label
do
if mount | grep $dev; then
echo -e "Already mounted"
else
if [ ! -d /mnt/$label ]; then
echo -n "Creating mount point..."
sudo mkdir /mnt/$label
fi
echo -n "Mounting......"$label
sudo mount $dev /mnt/$label
echo
if [ "$?" != "0" ]; then
echo "Mount failed. Exiting."
echo "" > ddc.txt
exit
fi
fi
done < ddc.txt