开发者

problem in reterving integer value in shellscript

开发者 https://www.devze.com 2023-02-17 15:30 出处:网络
pro* c code: shan.pc int main() { return 8000; } shellscript: #!/bin/ksh declare -i rc shan rc=$? echo \"$rc\";

pro* c code: shan.pc

int main()
{
    return 8000;
}

shellscript:

#!/bin/ksh
declare -i rc

shan
rc=$?

echo "$rc";

in script I called proc executable i got an output 128, rather then 8000. how can i receive 8000 in shellscript? please help me out?

solution:

int main()
    {
count=8000;
prinf("counter %d",count); 
        return 0;
    }

#!/bin/ksh
  rc=$(shan | awk '/counter/{print $2}')  开发者_JAVA技巧    
  echo "$rc"; 


You don't; the exit status of a program is restricted to -128 .. 127. printf() it instead and use rc=$(shan) in the script.

0

精彩评论

暂无评论...
验证码 换一张
取 消