0

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}')      
  echo "$rc"; 

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

9 Comments

i gave like this rc=$(shan),no value is getting printted.
Did you change shan.pc to printf the value instead of returning it?
do u mean int main() { printf(8000);}
int main() { printf("%d\n", 8000); return 0; } You're going to need to learn C if you're going to get anywhere with this.
i need to receive the value in script, in c i know it will print 8000.i need to echo the value in script which i receive from proc.. i dont need any printf. I am using a counter variable in a loop. i want this value of the counter to be returned to the script...
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.