The DNS Guys |
Anycast DNS 25 Nameservers Worldwide |
DNS Failover Host Monitoring & Auto Rollback |
Outbound SMTP Smart Relay, SASL |
| Subversion Hosting OpenID Servers & XMPP |
DNSSEC TSIG & Secondary DNS |
easyRoute53 Amazon Route53 GUI |
![]() ![]() |
Jan 3 2012, 11:13 PM
Post
#1
|
|
|
Whats this Lie-nix Thing? ![]() Group: Members Posts: 1 Joined: 3-January 12 Member No.: 15,804 |
First off I want to start off saying that I am working on this script for an Android phone, so the commands are generally limited to busybox. If busybox can't do it, then neither can I. This is the entire script I am working on:
CODE #!/sbin/sh if [ -e /dev/block/mtdblock0 ]; then if [ -d /data ]; then /tmp/busybox mount -t ext4 /dev/block/mmcblk0p2 /data else /tmp/busybox mkdir mkdir /data /tmp/busybox mount -t ext4 /dev/block/mmcblk0p2 /data fi if [ -h /data/data/ ]; then /tmp/busybox touch /tmp/nofix else if [ -d /datadata ]; then /tmp/busybox mount -t yaffs2 /dev/block/mtdblock6 /datadata else /tmp/busybox mkdir /datadata /tmp/busybox mount -t yaffs2 /dev/block/mtdblock6 /datadata fi /tmp/busybox rm -rf /datadata/* FREE_SPACE=$(/tmp/busybox df -h | /tmp/busybox awk '$1 == "/dev/block/mtdblock6" {print $3}'); USED_SPACE=$(/tmp/busybox du -sh /data/data/ | /tmp/busybox awk '{print $1}') NEW_TERM=$(echo $FREE_SPACE $USED_SPACE | /tmp/busybox awk '{print $1 $2}') FREE_SPACE=$(echo $NEW_TERM | /tmp/busybox awk '{print $1}'); USED_SPACE=$(echo $NEW_TERM | /tmp/busybox awk '{print $2}') if [ $FREE_SPACE -gt $USED_SPACE ]; then /tmp/busybox touch /tmp/revert_pass else /tmp/busybox touch /tmp/revert_fail fi fi else exit 1 fi All goes well and good, until I get to line 22: CODE NEW_TERM=$(echo $FREE_SPACE $USED_SPACE | /tmp/busybox awk '{print $1 $2}') Basically my problem is I need two integers to do the test in line 24: CODE if [ $FREE_SPACE -gt $USED_SPACE ]; then and the output from the command on line 21:CODE FREE_SPACE=$(/tmp/busybox df -h | /tmp/busybox awk '$1 == "/dev/block/mtdblock6" {print $3}'); USED_SPACE=$(/tmp/busybox du -sh /data/data/ | /tmp/busybox awk '{print $1}') is something like 132.5M for FREE_SPACE and 129.7M for USED_SPACE (I basically just made up those numbers, but they are numbers like that, 3 digits before the decimal, a digit after the decimal, and an M). What I am attempting to do with line 22 is try to maybe do 3 backspaces, if you will, on each of the two results. so 132.5M becomes 132 and 129.7M becomes 129. I don't need to know the decimal, it is really unimportant for my purposes. If I can accomplish that then I will be set for the rest of the script, but I really have no idea how to do that (or if its possible at all). |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 19th June 2013 - 05:03 PM |