I need to find a way to add a line to the /usr/local/etc/ipfw.conf file.
What I thought would be an easy script is giving me headaches and I am hoping one of you can point me in the right direction?
do shell script "cd /usr/local/etc/; vi ipfw.conf; i; 'add 00050 allow udp from any to any src-port 67 dist-port 68 in'; ^V ESC; :wq" with administrator privileges
It seems to be hanging on the ^V ESC?
Would there be a better way to accomplish this task?
What your doing is literally doing the things you’re doing in the terminal. This is not necessary when you’re automating processes on a computer. What we want is adding a simple line to the file and can be done by this
do shell script "echo 'add 00050 allow udp from any to any src-port 67 dist-port 68 in' >> /usr/local/etc/ipfw.conf"
This maybe the simplest way to do it but be aware that there are no checks if this line already exists or whatsoever. To make it idiot proof you need more to do, also for you own example.
Thank you. Sometimes my brain just doesn’t work right.
don’t be to hard on yourself. Everybody have one of those days.