genesis2000脚本(外挂接口)
- 格式:pdf
- 大小:415.51 KB
- 文档页数:2
Genesis2000脚本命令大全1.switch的用法,注意每一个case必须要以breaksw结尾否则会继续执行下一个case的命令(1)另外,$<的意思是取得使用者的stand input(2)echo若加上-n的选项,则游标会停留在该行最后echo-n"Input one color:"set STOPLIGHT=$<switch($STOPLIGHT)case red:echo"red"breakswcase orange:echo"orange"breakswcase green:echo"green"breakswdefault:echo"you input$STOPLIGHT"endsw--------------------------------------------------------------------2.利用set来取得变数,set ABC="I am ABC"也可以利用`command`来取得命令且外,case也可以用万用字元*来代替set VER=`uname-r`switch($VER)case5.5:echo"run the setup of$VER"breakswcase5.3:echo"run the setup of$VER"breakswcase5.*:echo"like5.x"breakswcase4.*:echo"like4.x"breakswdefault:echo"no idea"endsw--------------------------------------------------------------------3.if的语法,比较数字set n1=1set n2=2if($n1==$n2)thenecho"$n1Equal$n2"elseecho"$n1Not Equal$n2"endif--------------------------------------------------------------------4.if的语法,比较字串set n1=abcdefset n2=abcdeif($n1==$n2)thenecho"$n1Equal$n2"elseecho"$n1Not Equal$n2"--------------------------------------------------------------------5.if的语法,比较相似的字串set n1=abcdefset n2=abcdeif($n1=~$n2)thenecho"$n1Like$n2"elseecho"$n1Not Like$n2"endif--------------------------------------------------------------------6.if的语法,比较数字的大小set n1=1set n2=2if($n1>$n2)thenecho"$n1>$n2"echo"$n1<$n2"endif--------------------------------------------------------------------7.每分钟执行一次的程式#mm等于当天时间的【分钟】数set mm=`date|cut-d''-f4|cut-d:-f2`if(-r$0.out)thenrm$0.outtouch$0.outelsetouch$0.outendifwhile($mm<=16)set mm=`date|cut-d''-f4|cut-d:-f2`echo"$mm now is`date`"sleep60#echo"$mm now is`date`">>$0.outendecho"Over">>$0.out--------------------------------------------------------------------8.一个回圈的范例,并且利用expr去作加的动作回圈的语法如下:foreach number(123)echo$numberendset counter=0while($counter<=10)echo"sleeping for5seconds"sleep5counter=`expr$counter+1`end--------------------------------------------------------------------9.设定一个用当天月份与日期作为档案名称的程式如今天是10/02,则$prefix会等于该程式+1002date.csh1002set prefix=`basename$0``date'+%m%d'`echo$0echo$prefix--------------------------------------------------------------------10.移除在foreach回圈内指定的档案内的font字串foreach file([b,e,g,h,s]*.html)echo-n"Processing$file,remove the line number`grep-n font $file`"#$log表示这个$file有几个font字串set log=`grep-c font$file`if($log=='0')thenecho",pass$file"else#先找出该档案的第一次出现font的行数,如果3,则$cmd=3dset cmd=`grep-n font$file|cut-d:-f1|head-1`d#利用sed去执行删除的动作,并把结果输出到${file}1sed$cmd$file>${file}1#如果${file}1没有资料,则passingif(-z${file}1)thenecho",${file}1is zero"elsecp${file}1$filerm{$file}1echo",$file remove ok"endifendifend#后来看过sed的更进一步用法,发现先前写的太笨了,试试这个#sed/font/d$file>${file}1#一次OK,我真是大笨蛋--------------------------------------------------------------------11.功能:将指定的档案中,出现第一次【回】的那一行,加上<ti tle>xxxx</title>foreach file(sky*.html)set filetitle=ftitle#主要部份为sed部份s/^*//表示将该行第一个字元前的空白删除echo"<title>`grep回$file|head-1|sed-e's/^*//'`</tit le>">$ftitle#将刚刚那一行,再插回去head-1$file>${file}headsed1d$file>${file}1cat$ftitle>>${file}headcat${file}1>>${file}headcp${file}head$filerm${file}1rm$ftitlerm${file}headecho"$file ok"end--------------------------------------------------------------------12.一个实际建立一个ftp server的程式里面包括许多应用,相当有参考价值(未完成)set path=(/usr/bin/usr/sbin)#set true=`grep-c ftp/etc/passwd`if($true==0)thenecho"no ftp user in your system"echo-n"do you want to create the ftp user?"set answer=$<if($answer=='y'||$answer=='Y')thenset maxid=`sort/etc/passwd|tail-1|cut-d:-f3`echo$maxidset newid=`expr$maxid+1`echo$newidecho"/usr/sbin/useradd-d/home1/ftp-u$newid-s/etc/false ftp"endifelseecho"Good.Your system already has the ftp user."set ftphome=`grep ftp:/etc/passwd|cut-d:-f6`echo$ftphomeendifif(-z$ftphome)thenecho"ftphome must be non-null"exit2endifif($ftphome=="/usr"||$ftphome=="/")then echo"ftphome can't be/or/usr"exit2endif#create the ftp home directoryif(!-d$ftphome)thenecho"mkdir$ftphome"endifecho"Setting up the ftphome for SunOS`uname-r`"if(!-d$ftphome)thenecho"mkdir-p$ftphome/usr/bin"endifcp/bin/ls$ftphome/usr/binchmod111$ftphome/usr/bin/lschown root$ftphome/usr/binchmod555$ftphome/usr/binif(-r$ftphome/bin)thenmv-f$ftphome/bin$ftphome/Obinendifln-s usr/bin$ftphome--------------------------------------------------------------------13.取得该使用者的UIDif($#argv==0)thenecho"$0usage:$1username"exit2endifset uid=`grep$1/etc/passwd|cut-d:-f3`echo$uid--------------------------------------------------------------------14.将指定档案内的html取代成htmforeach file(*.html)echo"Processing$file..."sed s/html/htm/$file>${file}1cp${file}1$filerm${file}1end--------------------------------------------------------------------15.一个简简单单的范例,看看就好#!/bin/csh-f echo.................echo WELCOME to\*TAPE COPY\* echo.................echo Enter your name:#$<can read from stand inputset name=$<echo""echo Hi$name\!set D=`date`echo Today\'s date is$D[1]$D[2]$D[3]if($D[1]==Mon)thenecho-------------------------------------------------------------echo Today is$D[1]day$name,it\'s time to copy your director ys\!echo-------------------------------------------------------------elseecho-------------------------------------------------------------echo Today is$D[1]day$name,no tape copies today\!echo-------------------------------------------------------------endif--------------------------------------------------------------------16.一个finger的程式set FINGER="/usr/ucb/finger"if(-x$FINGER)thenif($#argv==0)thencat<<TAG---------------------------------Hahahah....---------------------------------TAGelse$FINGER"$*"endifelseecho"Cannot find finger on this system."endif--------------------------------------------------------------------17.取得变数的方法set W=`who-r`echo$W[9]--------------------------------------------------------------------18.更改档案名称,将*.html-->*.htm#rename*.html to*.htmecho-n"This will change*.html to*.htm.Can I continue?(y/n): "set input=$<if($input!="y"&&$input!="Y")thenecho"Ok.Quit..."exit2endifforeach file(*.html)echo"Processing$file to`basename$file.html`.htm"mv$file`basename$file.html`.htmend--------------------------------------------------------------------19.更改档案名称,将*.htm-->*.htmlecho-n"This will change*.htm to*.html.Can I continue?(y/n): "set input=$<if($input!="y"&&$input!="Y")thenecho"Ok.Quit..."exit2endif#rename*.htm to*.htmlforeach file(*.htm)echo"Processing$file to`basename$file.htm`.html"mv$file`basename$file.htm`.htmlend--------------------------------------------------------------------20.将大写的档名改成小写的档名tr string1string2会将standard input的字串,所对应到的string1,都以string2取代foreach file(*)mv$file`echo$file|tr'[A-Z]''[a-z]'`end--------------------------------------------------------------------21.将小写的档名改成大写的档名foreach file(*)mv$file`echo$file|tr'[a-z]''[A-Z]'`end。
1. switch 的用法,注意每一个case 必须要以breaksw 结尾 否则会继续执行下一个case 的命令(1) 另外,$< 的意思是取得使用者的stand input(2) echo 若加上-n 的选项,则游标会停留在该行最后echo -n "Input one color: "set STOPLIGHT = $<switch ($STOPLIGHT)case red:echo "red"breakswcase orange:echo "orange"breakswcase green:echo "green"breakswdefault:echo "you input $STOPLIGHT"endsw--------------------------------------------------------------------2. 利用set 来取得变数,set ABC = "I am ABC"也可以利用`command` 来取得命令且外,case 也可以用万用字元* 来代替set VER = `uname -r`switch ($VER)case 5.5:echo "run the setup of $VER"breakswcase 5.3:echo "run the setup of $VER"breakswcase 5.*:echo "like 5.x"breakswcase 4.*:echo "like 4.x"breakswdefault:echo "no idea"endsw--------------------------------------------------------------------3. if 的语法,比较数字set n1 = 1set n2 = 2if ($n1 == $n2) thenecho "$n1 Equal $n2"elseecho "$n1 Not Equal $n2"endif--------------------------------------------------------------------4. if 的语法,比较字串set n1 = abcdefset n2 = abcdeif ($n1 == $n2) thenecho "$n1 Equal $n2"elseecho "$n1 Not Equal $n2"endif--------------------------------------------------------------------5. if 的语法,比较相似的字串set n1 = abcdefset n2 = abcdeif ($n1 =~ $n2) thenecho "$n1 Like $n2"elseecho "$n1 Not Like $n2"endif--------------------------------------------------------------------6. if 的语法,比较数字的大小set n1 = 1set n2 = 2if ($n1 > $n2) thenecho "$n1 > $n2"elseendif--------------------------------------------------------------------7. 每分钟执行一次的程式# mm 等于当天时间的【分钟】数set mm = `date | cut -d' ' -f4 | cut -d: -f2`if ( -r $0.out ) thenrm $0.outtouch $0.outelsetouch $0.outendifwhile ( $mm <= 16 )set mm = `date | cut -d' ' -f4 | cut -d: -f2`echo "$mm now is `date`"sleep 60#echo "$mm now is `date`" >> $0.outendecho "Over" >> $0.out--------------------------------------------------------------------8. 一个回圈的范例,并且利用expr 去作加的动作回圈的语法如下:foreach number (1 2 3)echo $numberendset counter = 0while ($counter <= 10)echo "sleeping for 5 seconds"sleep 5counter = `expr $counter + 1 `end--------------------------------------------------------------------9. 设定一个用当天月份与日期作为档案名称的程式如今天是10/02 , 则$prefix 会等于该程式+ 1002set prefix = `basename $0``date '+ %m%d'`echo $0echo $prefix--------------------------------------------------------------------10. 移除在foreach 回圈内指定的档案内的font 字串foreach file ([b,e,g,h,s]*.html)echo -n "Processing $file, remove the line number `grep -n font $file`"# $log 表示这个$file 有几个font 字串set log = `grep -c font $file`if ( $log == '0' ) thenecho ", pass $file"else# 先找出该档案的第一次出现font 的行数,如果3,则$cmd = 3dset cmd = `grep -n font $file | cut -d: -f1 | head -1`d# 利用sed 去执行删除的动作,并把结果输出到${file}1sed $cmd $file > ${file}1# 如果${file}1 没有资料,则passingif ( -z ${file}1 ) thenecho " , ${file}1 is zero"elsecp ${file}1 $filerm {$file}1echo " , $file remove ok"endifendifend# 后来看过sed 的更进一步用法,发现先前写的太笨了,试试这个# sed /font/d $file > ${file}1# 一次OK, 我真是大笨蛋--------------------------------------------------------------------11. 功能:将指定的档案中,出现第一次【回】的那一行,加上<title> xxxx </title>foreach file (sky*.html)set filetitle = ftitle# 主要部份为sed 部份 s/^ *// 表示将该行第一个字元前的空白删除echo "<title>`grep 回$file | head -1 | sed -e 's/^ *//'`</title>" > $ftitle# 将刚刚那一行,再插回去head -1 $file > ${file}headsed 1d $file > ${file}1cat $ftitle >> ${file}headcat ${file}1 >> ${file}headcp ${file}head $filerm ${file}1rm $ftitlerm ${file}headecho "$file ok"end--------------------------------------------------------------------12. 一个实际建立一个ftp server 的程式 里面包括许多应用,相当有参考价值( 未完成)set path = ( /usr/bin /usr/sbin )#set true = `grep -c ftp /etc/passwd`if ( $true == 0 ) thenecho "no ftp user in your system"echo -n "do you want to create the ftp user? "set answer = $<if ($answer == 'y' || $answer == 'Y') thenset maxid = `sort /etc/passwd | tail -1 | cut -d: -f3`echo $maxidset newid = `expr $maxid + 1`echo $newidecho "/usr/sbin/useradd -d /home1/ftp -u $newid -s /etc/false ftp"endifelseecho "Good. Your system already has the ftp user. "set ftphome = `grep ftp: /etc/passwd | cut -d: -f6`echo $ftphomeendifif ( -z $ftphome ) thenecho "ftphome must be non-null"exit 2endifif ( $ftphome == "/usr" || $ftphome == "/" ) thenecho "ftphome can't be / or /usr"exit 2endif# create the ftp home directoryif ( ! -d $ftphome ) thenecho "mkdir $ftphome"endifecho "Setting up the ftphome for SunOS `uname -r`"if ( ! -d $ftphome ) thenecho "mkdir -p $ftphome/usr/bin"endifcp /bin/ls $ftphome/usr/binchmod 111 $ftphome/usr/bin/lschown root $ftphome/usr/binchmod 555 $ftphome/usr/binif ( -r $ftphome/bin ) thenmv -f $ftphome/bin $ftphome/Obinendifln -s usr/bin $ftphome--------------------------------------------------------------------13. 取得该使用者的UIDif ( $#argv == 0 ) thenecho "$0 usage: $1 username"exit 2endifset uid = `grep $1 /etc/passwd | cut -d: -f3`echo $uid--------------------------------------------------------------------14. 将指定档案内的html 取代成htmforeach file ( *.html )echo "Processing $file ..."sed s/html/htm/ $file > ${file}1cp ${file}1 $filerm ${file}1end--------------------------------------------------------------------15. 一个简简单单的范例,看看就好#!/bin/csh -fecho .................echo WELCOME to \* TAPE COPY \*echo .................echo Enter your name:# $< can read from stand inputset name = $<echo " "echo Hi $name \!set D = `date`echo Today\'s date is $D[1] $D[2] $D[3]if ($D[1] == Mon) thenecho -------------------------------------------------------------echo Today is $D[1]day $name, it\'s time to copy your directorys\! echo -------------------------------------------------------------elseecho -------------------------------------------------------------echo Today is $D[1]day $name, no tape copies today\!echo -------------------------------------------------------------endif--------------------------------------------------------------------16. 一个finger 的程式set FINGER = "/usr/ucb/finger"if ( -x $FINGER ) thenif ( $#argv == 0 ) thencat << TAG---------------------------------Hahahah ....---------------------------------TAGelse$FINGER "$*"endifelseecho "Cannot find finger on this system."endif--------------------------------------------------------------------17. 取得变数的方法set W = `who -r`echo $W[9]--------------------------------------------------------------------18. 更改档案名称,将*.html --> *.htm# rename *.html to *.htmecho -n "This will change *.html to *.htm. Can I continue ? (y/n) : " set input = $<if ( $input != "y" && $input != "Y" ) thenecho "Ok. Quit..."exit 2endifforeach file ( *.html )echo "Processing $file to `basename $file .html`.htm "mv $file `basename $file .html`.htmend--------------------------------------------------------------------19. 更改档案名称,将*.htm --> *.htmlecho -n "This will change *.htm to *.html. Can I continue ? (y/n) : " set input = $<if ( $input != "y" && $input != "Y" ) thenecho "Ok. Quit..."exit 2endif# rename *.htm to *.htmlforeach file ( *.htm )echo "Processing $file to `basename $file .htm`.html " mv $file `basename $file .htm`.htmlend--------------------------------------------------------------------20. 将大写的档名改成小写的档名tr string1 string2 会将standard input 的字串,所对应到的string1, 都以string2 取代foreach file ( * )mv $file `echo $file | tr '[A-Z]' '[a-z]'`end--------------------------------------------------------------------21. 将小写的档名改成大写的档名foreach file (*)mv $file `echo $file | tr '[a-z]' '[A-Z]'`end</P< p>。
1. switch 的用法,注意每一个case 必须要以breaksw 结尾否则会继续执行下一个case 的命令(1) 另外,$< 的意思是取得使用者的stand input(2) echo 若加上-n 的选项,则游标会停留在该行最后echo -n "Input one color: "set STOPLIGHT = $<switch ($STOPLIGHT)case red:echo "red"breakswcase orange:echo "orange"breakswcase green:echo "green"breakswdefault:echo "you input $STOPLIGHT"endsw--------------------------------------------------------------------2. 利用set 来取得变数,set ABC = "I am ABC"也可以利用`command` 来取得命令且外,case 也可以用万用字元* 来代替set VER = `uname -r`switch ($VER)case 5.5:echo "run the setup of $VER"breakswcase 5.3:echo "run the setup of $VER"breakswcase 5.*:echo "like 5.x"breakswcase 4.*:echo "like 4.x"breakswdefault:echo "no idea"endsw-------------------------------------------------------------------- 3. if 的语法,比较数字set n1 = 1set n2 = 2if ($n1 == $n2) thenecho "$n1 Equal $n2"elseecho "$n1 Not Equal $n2"endif-------------------------------------------------------------------- 4. if 的语法,比较字串set n1 = abcdefset n2 = abcdeif ($n1 == $n2) thenecho "$n1 Equal $n2"elseecho "$n1 Not Equal $n2"endif-------------------------------------------------------------------- 5. if 的语法,比较相似的字串set n1 = abcdefset n2 = abcdeif ($n1 =~ $n2) thenecho "$n1 Like $n2"elseecho "$n1 Not Like $n2"endif-------------------------------------------------------------------- 6. if 的语法,比较数字的大小set n1 = 1set n2 = 2if ($n1 > $n2) thenecho "$n1 > $n2"elseecho "$n1 < $n2"endif-------------------------------------------------------------------- 7. 每分钟执行一次的程式# mm 等于当天时间的【分钟】数set mm = `date | cut -d' ' -f4 | cut -d: -f2`if ( -r $0.out ) thenrm $0.outtouch $0.outelsetouch $0.outendifwhile ( $mm <= 16 )set mm = `date | cut -d' ' -f4 | cut -d: -f2`echo "$mm now is `date`"sleep 60#echo "$mm now is `date`" >> $0.outendecho "Over" >> $0.out-------------------------------------------------------------------- 8. 一个回圈的范例,并且利用expr 去作加的动作回圈的语法如下:foreach number (1 2 3)echo $numberendset counter = 0while ($counter <= 10)echo "sleeping for 5 seconds"sleep 5counter = `expr $counter + 1 `end-------------------------------------------------------------------- 9. 设定一个用当天月份与日期作为档案名称的程式如今天是10/02 , 则$prefix 会等于该程式+ 1002date.csh1002set prefix = `basename $0``date '+ %m%d'`echo $0echo $prefix--------------------------------------------------------------------10. 移除在foreach 回圈内指定的档案内的font 字串foreach file ([b,e,g,h,s]*.html)echo -n "Processing $file, remove the line number `grep -n font $file`"# $log 表示这个$file 有几个font 字串set log = `grep -c font $file`if ( $log == '0' ) thenecho ", pass $file"else# 先找出该档案的第一次出现font 的行数,如果3,则$cmd = 3dset cmd = `grep -n font $file | cut -d: -f1 | head -1`d# 利用sed 去执行删除的动作,并把结果输出到${file}1sed $cmd $file > ${file}1# 如果${file}1 没有资料,则passingif ( -z ${file}1 ) thenecho " , ${file}1 is zero"elsecp ${file}1 $filerm {$file}1echo " , $file remove ok"endifendifend# 后来看过sed 的更进一步用法,发现先前写的太笨了,试试这个# sed /font/d $file > ${file}1# 一次OK, 我真是大笨蛋--------------------------------------------------------------------11. 功能:将指定的档案中,出现第一次【回】的那一行,加上<title> xxxx </title>foreach file (sky*.html)set filetitle = ftitle# 主要部份为sed 部份s/^ *// 表示将该行第一个字元前的空白删除echo "<title>`grep 回$file | head -1 | sed -e 's/^ *//'`</title>" > $ftitle# 将刚刚那一行,再插回去head -1 $file > ${file}headsed 1d $file > ${file}1cat $ftitle >> ${file}headcat ${file}1 >> ${file}headcp ${file}head $filerm ${file}1rm $ftitlerm ${file}headecho "$file ok"end--------------------------------------------------------------------12. 一个实际建立一个ftp server 的程式里面包括许多应用,相当有参考价值( 未完成)set path = ( /usr/bin /usr/sbin )#set true = `grep -c ftp /etc/passwd`if ( $true == 0 ) thenecho "no ftp user in your system"echo -n "do you want to create the ftp user? "set answer = $<if ($answer == 'y' || $answer == 'Y') thenset maxid = `sort /etc/passwd | tail -1 | cut -d: -f3`echo $maxidset newid = `expr $maxid + 1`echo $newidecho "/usr/sbin/useradd -d /home1/ftp -u $newid -s /etc/false ftp"endifelseecho "Good. Your system already has the ftp user. "set ftphome = `grep ftp: /etc/passwd | cut -d: -f6`echo $ftphomeendifif ( -z $ftphome ) thenecho "ftphome must be non-null"exit 2endifif ( $ftphome == "/usr" || $ftphome == "/" ) then echo "ftphome can't be / or /usr"exit 2endif# create the ftp home directoryif ( ! -d $ftphome ) thenecho "mkdir $ftphome"endifecho "Setting up the ftphome for SunOS `uname -r`"if ( ! -d $ftphome ) thenecho "mkdir -p $ftphome/usr/bin"endifcp /bin/ls $ftphome/usr/binchmod 111 $ftphome/usr/bin/lschown root $ftphome/usr/binchmod 555 $ftphome/usr/binif ( -r $ftphome/bin ) thenmv -f $ftphome/bin $ftphome/Obinendifln -s usr/bin $ftphome-------------------------------------------------------------------- 13. 取得该使用者的UIDif ( $#argv == 0 ) thenecho "$0 usage: $1 username"exit 2endifset uid = `grep $1 /etc/passwd | cut -d: -f3`echo $uid-------------------------------------------------------------------- 14. 将指定档案内的html 取代成htmforeach file ( *.html )echo "Processing $file ..."sed s/html/htm/ $file > ${file}1cp ${file}1 $filerm ${file}1end--------------------------------------------------------------------15. 一个简简单单的范例,看看就好#!/bin/csh -fecho .................echo WELCOME to \* TAPE COPY \*echo .................echo Enter your name:# $< can read from stand inputset name = $<echo " "echo Hi $name \!set D = `date`echo Today\'s date is $D[1] $D[2] $D[3]if ($D[1] == Mon) thenecho -------------------------------------------------------------echo Today is $D[1]day $name, it\'s time to copy your directorys\!echo -------------------------------------------------------------elseecho -------------------------------------------------------------echo Today is $D[1]day $name, no tape copies today\!echo -------------------------------------------------------------endif--------------------------------------------------------------------16. 一个finger 的程式set FINGER = "/usr/ucb/finger"if ( -x $FINGER ) thenif ( $#argv == 0 ) thencat << TAG---------------------------------Hahahah ....---------------------------------TAGelse$FINGER "$*"endifelseecho "Cannot find finger on this system."endif--------------------------------------------------------------------17. 取得变数的方法set W = `who -r`echo $W[9]--------------------------------------------------------------------18. 更改档案名称,将*.html --> *.htm# rename *.html to *.htmecho -n "This will change *.html to *.htm. Can I continue ? (y/n) : " set input = $<if ( $input != "y" && $input != "Y" ) thenecho "Ok. Quit..."exit 2endifforeach file ( *.html )echo "Processing $file to `basename $file .html`.htm "mv $file `basename $file .html`.htmend--------------------------------------------------------------------19. 更改档案名称,将*.htm --> *.htmlecho -n "This will change *.htm to *.html. Can I continue ? (y/n) : " set input = $<if ( $input != "y" && $input != "Y" ) thenecho "Ok. Quit..."exit 2endif# rename *.htm to *.htmlforeach file ( *.htm )echo "Processing $file to `basename $file .htm`.html "mv $file `basename $file .htm`.htmlend-------------------------------------------------------------------- 20. 将大写的档名改成小写的档名tr string1 string2 会将standard input 的字串,所对应到的string1, 都以string2 取代foreach file ( * )mv $file `echo $file | tr '[A-Z]' '[a-z]'`end-------------------------------------------------------------------- 21. 将小写的档名改成大写的档名foreach file (*)mv $file `echo $file | tr '[a-z]' '[A-Z]'`end</P< p>。
自动化阻抗制作脚本使用说明1,脚本运行环境:WINDOWS 操作系统,GENESIS8.2、GENESIS9.1、GENESIS9.2、GENESIS9.8 2,制作阻抗测试条种类。
差动阻抗(DF),特性阻抗(SE)。
3,程式运行界面和介绍。
阻抗信息显示区。
A,阻抗信息录入,首先阻搞信息,请确定录入阻抗是的状态,如果状态不对,参考资料将保证是正B.TopRefLayer : 阻抗顶层,即顶层C.BotRefLayer: 阻抗不,测试阻抗条底层。
D.ArtWorkLine :工作稿线宽。
E.ArtWorkSpacing :工作稿线距。
F.SafeCopperSpacing:阻抗线线距铜皮距离。
G.SafeCopperWidthMin:保护铜皮最小宽度。
H.Imp:阻抗值(注:此参数仅添加文字标注时用)。
I.ImpTol:阻抗公差(注:此参数仅添加文字标注时用)。
J.阻抗条宽:测试条宽度。
K.阻抗条长:阻抗条长度。
L.阻抗定位孔:阻抗定位孔左右各一个(左右距板边各1.5MM,上下居阻抗条宽中心)。
M.阻抗测试孔:阻抗测试孔大小为1.00mm。
单组阻抗信息:New:选项:新增阻抗,点击《添加阻抗参数》为新增一组阻抗值。
View选项:点击《添加阻抗参数》,自动计算阻抗组数和添加阻抗条数量,以及查看当Order组数的详细信息。
Edit选项:双击阻抗信息显示区对应ORDER对应组数如下,刚才当前为View,修改时点选EDIT,修改当前组抗条的参数,再选《添加阻抗参数》执行编辑。
所有阻抗参数添加OK后,执行《添加阻抗条》。
结果如下:。
genesis2000脚本GUI界面编写下面就是Genesis的GUI的demo程序,从里面可以学到几乎全部的GUI的功能了.前面的变量设定的部份省略不讲,大家可以参考Shell编程#!/bin/csh# This script is for GUI demo.############################################################## ####################alias gui '${GENESIS_DIR}/e${GENESIS_VER}/all/gui'alias gui_out 'echo !:* >> $GuiDefFile'alias gui_lst 'cat !:* >> $GuiDefFile'alias dogui 'gui < $GuiDefFile > $GuiDatFile; source $GuiDatFile; rm -f $GuiDefFile $GuiDatFile'if ($?GENESIS_TMP) thenset TMP = $GENESIS_TMPelse if ($?GENESIS_DIR) thenset TMP = $GENESIS_DIR/tmpelseset TMP = /genesis/tmpendif# Set gui parametersset GuiDefFile = $TMP/GuiDefFile.$$set GuiDatFile = $TMP/GuiDatFile.$$# Set fonts for gui #设定字体前三码表示字体格式,后两码数字表示大小#格式三码h 表字型(可选t) b表字宽粗体(bold)(可选m,细体) r表字正(可选i 表斜体)set TitleFont = hbr18set NormFont = hbr14set HintFont = hbi14# Set colors for gui #颜色是用RGB的型式表示,可以用Genesis中OPTION下COLOR功能来选自己喜欢的,#然后设定到GUI中去每一种颜色用两位数字表示99表示最深00表示最浅依次为R-red G-Green B-Blueset RedColor = 990000set WhiteColor = 999999set TitleColor = 772288set NormColor = 222299############################################################## #set job_list = `dbutil list jobs | awk '{print $1}'`gui_out WIN 200 200 #确定GUI窗口左上角在屏幕中的位置gui_out BG $WhiteColor #BG background背景颜色gui_out LABEL @/tmp/orblogo.xbm #添加标签(可以是一串字符,也可以是一个XPM格式图片我们在#后面会讨论如果制作这种图片,在6.如何加入中文里有说明)gui_out BG $TitleColorgui_out FG $WhiteColor #FG font ground字体颜色gui_out LABEL GUI Demogui_out BG $NormColorgui_out TEXT user_name User name : #TEXT文字输入窗口,并将值传给user_name变量, 显示”User name”gui_out DTEXT user_name Beyond Li #设定文字窗口的初始值Default TEXT=>DTEXT, 初始为Beyond Ligui_out BW 3 #BW 区隔线宽BOLD Width 设为3gui_out FORM #表格开始gui_out LABEL 'Select Job -->'gui_out LIST StepJob 5 S 1 #LIST列表选择功能StepJob为变量5表示显示5行S表示单选#多选为M, 1表示显示时从第1个项目开始显示foreach JobName ($job_list) #这里将除了genesislib以外的所有料号名都显示于LIST列表中if ($JobName != "genesislib") thengui_out $JobName #列表的内容endifendgui_out END #LIST功能结束(LIST传回的值为具体的列表中的值)gui_out ENDFORM #表格结束gui_out BW 1gui_out OPTION pnl_size Panel size: #OPTION下拉选项功能pnl_size 为变量显示”Panel size”gui_out 16x18 #选项的内容gui_out 18x24gui_out 20x24gui_out END #选项功能结束(OPTION传回的值为项目内容具体的值如16x18等)gui_out RADIO sel_pnl 'Panel name method:' H 1 $RedColor #RADIO点选功能变量为sel_p nl “’ . ’”为显示内容#H表示水平显示1表示一栏来显示最后是颜色gui_out Default #供点选的内容gui_out Keyingui_out END #点选功能结束gui_out FORM sel_pnl 2 #表格开始注意到后面有变量sel_pnl 2表示当sel_pnl选2时表格#才显现出来否则将以阴影不可编辑或选择的方式来显示gui_out TEXT pnl_name Panel name:gui_out ENDFORMgui_out CLABEL OK #按钮功能显示”OK”gui_out END #功能结束dogui #将这些传到GUI的程序中,它就会生成我们要的GUI界面.笔者通常在GUI最后,dogui之前加入一个RADIO让人员可以选择是否退出如下gui_out RADIO Exit_Chk 'Exit:' H 1 $RedColor #RADIO点选功能变量为sel_pnl “’ . ’”为显示内容#H表示水平显示1表示一栏来显示最后是颜色gui_out No #供点选的内容gui_out Yesgui_out END #点选功能结束在dogui后紧接着就设置检查if ( $Exit_Chk == 2 ) thenexit 0endif这样就可随时推出目前的GUI画面.其它的应用大家就要思考自己的工作要求,然后将这些功能灵活使用了.。
本章内容主要介绍genesis自动化程序编写运行环境:首先对genesis2000软件进行简单的介绍;而后介绍genesis2000自动化程序的开发方式和开发语言;最后介绍自动化程序在软件中的接口。
1.1、 genesis2000软件简介:Genesis2000软件是由Orbotech与Valor的合资公司—Frontline公司开发的CAM系统,其目的是为实工程现制前自动化,为CAM处理提供最佳解决方案,由于该软件拥有很强大的功能,很多PCB生产公司都已使用它为CAM 制前服务,笔者认为该软件有以下几方面的优点:1)令人喜欢的操作界面genesis2000软件界面设计人性化,操作简单,易学。
2)用ODB++格式,使用ODB++格式有以下三个优点:(1):使设计和制造之间数据交换最优化。
(2):目前唯一性的可扩充的结构。
(3):更精确的数据描述。
3)强大的操作辅助指令genesis2000软件的操作辅助指令可以简化很多复杂的工作,很简单的操作就可以达到我们想要的目的。
4)大的分析和优化功能genesis2000软件的Analysis和DFM功能在精密度要求越来越高的PCB行业显得极为重要,它自动进行精密的分析和优化,而用手动操作根本不可能实现。
5)自动化程序开发genesis2000软件的自动化程序可以让我们任何有规律的操作,有迹可寻的设定变成自动化,大大节省制作时间和减少人为误操作。
6)不断的围绕用户升级genesis2000软件不断围绕用户的需求进行开发新的实用的功能,笔者在使用的几年间,genesis2000开发了很多新的功能。
1.2:genesis2000软件自动化程序开发方式和语言:1.2.1genesis2000软件自动化程序的编写方式可分为以下三种:1)scripts2)hooks3)forms and flows1.2.2genesis2000软件自动化程序编写语言genesis2000软件自动化程序编写语言可以用多种语言进行实现:如SH、CSH、BSH、KSH、TCL/TK、PERL/TK,等等,本书主要介绍CSH,和PERL/TK两种比较常用的编写语言。
在genesis2000编程中,我们需要很多genesis自身已经定义的变量,并且在变量后面跟上不同的参数,会得到genesis里面很多的内定值(比如层的属性),使用这些内定值会使我们的程序编写简单,且让程序更有价值,下面我们将详细讲述这部分内容。
4.1:info简介:在genesis2000中,我们可以通过info指令得到genesis database里面的各种信息,我们可以把这些信息写到程序里面,实现genesis自动化,info指令格式如下:COM info,args = -t <type> -e <entity_path> \-d <data type> -p <parameters>, [-s serial_number]\[-o options] –help\out_file=~/out_file, write_mode = <replace | append>source ~/out_file在我们把info写进程序时,为书写方便,我们把它简写为DO_INFO,这个简写别名在$GENESIS_DIR/sys/hooks/script_start.csh中已自动定义,其定义的内容如下:alias DO_INFO 'set IFILE = /tmp/info.$$; \\COM info,out_file=$IFILE,write_mode=replace,args= \!:* ; \\source $IFILE; rm $IFILE'如果你发现DO_INFO不能使用,则可按照上面内容进行定义:4.2:info参数定义:在上面我们讲述info的格式,它的参数有4个,如下:(1):out_file 定义将信息输出文件的路径及文件名,如/tmp/info(2):units 设置输出资料的单位,是inch还是mm。
自动化程序编写和运行环境本章内容主要介绍genesis自动化程序编写运行环境:首先对genesis2000软件进行简单的介绍;而后介绍genesis2000自动化程序的开发方式和开发语言;最后介绍自动化程序在软件中的接口。
1.1、 genesis2000软件简介:Genesis2000软件是由Orbotech与Valor的合资公司—Frontline公司开发的CAM系统,其目的是为实工程现制前自动化,为CAM处理提供最佳解决方案,由于该软件拥有很强大的功能,很多PCB生产公司都已使用它为CAM 制前服务,笔者认为该软件有以下几方面的优点:1)令人喜欢的操作界面genesis2000软件界面设计人性化,操作简单,易学。
2)用ODB++格式,使用ODB++格式有以下三个优点:(1):使设计和制造之间数据交换最优化。
(2):目前唯一性的可扩充的结构。
(3):更精确的数据描述。
3)强大的操作辅助指令genesis2000软件的操作辅助指令可以简化很多复杂的工作,很简单的操作就可以达到我们想要的目的。
4)大的分析和优化功能genesis2000软件的Analysis和DFM功能在精密度要求越来越高的PCB行业显得极为重要,它自动进行精密的分析和优化,而用手动操作根本不可能实现。
5)自动化程序开发genesis2000软件的自动化程序可以让我们任何有规律的操作,有迹可寻的设定变成自动化,大大节省制作时间和减少人为误操作。
6)不断的围绕用户升级genesis2000软件不断围绕用户的需求进行开发新的实用的功能,笔者在使用的几年间,genesis2000开发了很多新的功能。
1.2:genesis2000软件自动化程序开发方式和语言:1.2.1genesis2000软件自动化程序的编写方式可分为以下三种:1)scripts2)hooks3)forms and flows1.2.2genesis2000软件自动化程序编写语言genesis2000软件自动化程序编写语言可以用多种语言进行实现:如SH、CSH、BSH、KSH、TCL/TK、PERL/TK,等等,本书主要介绍CSH,和PERL/TK两种比较常用的编写语言。