This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: svn and exits. When the script receives the parameter stop it terminates the execution of program svn (it can obtain its PID by means of command ps ) Example: runsvn.sh start runsvn.sh stop example of solution : #!/bin/bash if [ $1 = "start" ] then #echo "start" svn exit 0 fi if [ $1 = "stop" ] then #echo "stop" a=$(ps | cut -s " " -f 2,9 | grep "svn" | cut -d ' ' -f 2) kill -9 $a exit 0 fi echo "Usage error" 3. Implement a shell script that takes one parameter N from the input line, and produces N terms of the Fibonacci series. In the Fibonacci series, the first two terms are equal to 1 . Every successive term can be obtained by summing the two preceding terms: s(0)=1; s(1)=1; s(2)=s(0)+s(1)=2; s(3)=s(1)+s(2)=3; . . . . s(n)=s(n-2)+s(n-1) example of solution : #!/bin/bash if [ $1 -ge 1 ] then a=1 echo $a fi if [ $1 -ge 2 ] then b=1 echo $b fi for((n=3;n<=$1;n++)) do c=$[$a+$b] echo $c; a=$b b=$c done...
View Full Document
This note was uploaded on 11/04/2008 for the course INF EE056K taught by Professor Laface during the Winter '08 term at Politecnico di Torino.
- Winter '08