ChinaUnix.net
相关文章推荐:

shell脚本函数

各位大大~~~~大家辛苦了 小弟发一个脚本 ……………………………………………………………… function PING_STATUS () { local _ipadd _ipadd=$1 PING_COUNT=`ping -c 4 $1` if [ $? -eq 0 ];then # return 0 echo "ping is ok" #ping success elif [ $? -ne 0 ];then # return 1 echo "ping is error" #ping error fi } PING_STATUS $IP …………………...

by ppiqq - Shell - 2008-12-18 12:31:59 阅读(4779) 回复(16)

相关讨论

比如下面的shell脚本文件: #===========test.sh: #! /bin/sh echo_line() { echo date echo "Wellcome to shell func!" } echo_hello() { echo "Hello World!" } #====================== 怎么在shell下调用以上两个函数啊? 为什么我用【./test.sh echo_hello】却什么也没有输出? 当然,我已经给test.sh加了可执行权限了。

by apple_7095 - Linux环境编程 - 2013-11-03 01:39:48 阅读(2440) 回复(4)

[test@erpdataserver ~]$ cat kkg.sh #!/bin/bash funion (){ echo "1" echo $1 } funion [test@erpdataserver ~]$ ./kkg.sh test 1 [test@erpdataserver ~]$ test值 echo不出来。 以前碰到过,现在不记得了。

by 我是DBA - Shell - 2009-01-20 12:21:44 阅读(2269) 回复(7)

本帖最后由 General_715 于 2013-01-17 15:27 编辑 比如 a.sh 要调用b.sh 在a.sh中有一个函数 b.sh也要使用 直接调用的话没好用 cat a.sh #!/bin/sh ECHO(){ echo "aaa" } . /home/b.sh cat b.sh #!/bin/sh ECHO 这样直接调用的话不好用 有什么办法吗

by General_715 - Shell - 2013-01-17 15:28:56 阅读(1353) 回复(1)

比如我在一台中控机器上写了个脚本 #! /bin/sh FUN { echo "what is you name" } ssh 1.1.1.1 " FUN" 就是在一个SSH的脚本里面如何调用这个FUN函数, 当这么执行的时候,会提示FUN:command not found 谢谢各位大侠~~!

by 本大王 - Linux新手园地 - 2012-09-26 22:08:45 阅读(4760) 回复(4)

file a.c #include int main() { int i; for(i=0; i<10; i++) { printf("%d\n",i); } return 15; } gcc -o a a.c 如何在shell脚本中接收a的返回值呢

by daniel_kohler - Shell - 2010-01-19 14:23:24 阅读(3775) 回复(4)

请问,使用shell脚本,有没有画线的函数呢? 还有就是在unix的C,需要自己手工编译器吗?

by wyh84 - Shell - 2007-03-07 00:25:33 阅读(1275) 回复(2)

HPUX下的shell函数定义格式是啥样的 俺用 function yesterday() {...} 报错:Syntax error at line 4 : `(' is not expected. 可是在cygwin下可以用

by starndawn - HP-UX - 2006-06-16 17:47:52 阅读(1318) 回复(1)

HPUX下的shell函数定义格式是啥样的 俺用 function yesterday() {...} 报错:Syntax error at line 4 : `(\' is not expected. 可是在cygwin下可以用

by starndawn - HP-UX - 2006-06-16 17:47:52 阅读(3078) 回复(1)

如题 求 办法 附上代码: #!/bin/sh db_insert() { sql="insert into testTable(id , name) values('' , '$1')"; mysql -h192.168.1.1 -P3306 -utestUser -ptestPwd -e "$sql"; } awk 'BEGIN{ FS="\t"; } { 我想在这个地方调用,函数db_insert 并代入参数 $1 db_insert } END { }' "test.txt" 只知道调用系统函数 用 system(); 不知道这个怎么调?新手请高手帮助!!

by claudeyuan - Shell - 2008-09-11 14:50:41 阅读(3806) 回复(5)

我是这么写的,先写一个函数,然后运行它(得到一个日期是星期几),代码如下 echo '昨天是星期' echo `get_whatdays` 20030103 get_whatdays() { yy=`echo $1|cut -c 1-4` mm=`echo $1|cut -c 5-6` dd=`echo $1|cut -c 7-8` expr $dd : 0. > /dev/null && dd=`echo $dd|cut -c 2-2` aaa=`eval cal $mm $yy|grep " 20 "|cut -c 1-2` dd=`expr \( $dd - $aaa \) \% 7` [ $dd -lt 0 ] && dd=`expr $dd + 7` echo $dd } 可是...

by ohwww - Shell - 2003-06-19 15:05:12 阅读(6607) 回复(7)