On Thu, 12 Dec 2013, Craig Sanders wrote: > On Thu, Dec 12, 2013 at 10:33:32PM +1100, Allan Duncan wrote: > > I have a rc.local script that runs fine in csh, but I'd like to change > > it to sh, but I've had no success at it. > > > > #! /usr/bin/tcsh > > if `ping -w 1 -c 1 -n 192.168.1.3 | grep -o "1 packets"` == "1 packets" > > mount /nfs/bulk2 > > the simplest conversion to sh (with some fixes*) would be something like: > > #!/bin/sh > if $(ping -w 1 -c 1 -n 192.168.1.3 | grep -q "1 packets") ; then > mount /nfs/bulk2 > fi
bash only. (ie, #!/bin/bash) > or as a one-liner: > > #!/bin/sh > ping -w 1 -c 1 -n 192.168.1.3 | grep -q "1 packets" && mount /nfs/bulk2 > > > * fixes: > > 1. backticks are pretty much deprecated. use $(...) instead - it's > clearer/more readable, avoids most shell quoting/escaping problems, and > can be nested. Um, no, as I've said before, $() is a bashism. Yes it is neater, but try running that on HP-UX and see how well you go. -- Tim Connors _______________________________________________ luv-main mailing list [email protected] http://lists.luv.asn.au/listinfo/luv-main
