0

I have a C program in which two scanf() are done.

I need to write a shellscript that will run the program and give it the arguments too.

The problem is that all I could come up with is how to pipeline an argument into the program as a command line arguments which is not what I need.

Any help appreciated.

2
  • Can you post what you have tried.. You have mentioned that you have tried some thing related to pipe lining. Commented Mar 5, 2012 at 2:25
  • @Ajai perl -e' print"input";' | program Commented Mar 5, 2012 at 2:29

1 Answer 1

1

This should work

echo "some input" | yourprog

e.g. echo "1 1 + p" | dc

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

3 Comments

In what way is this not using pipeline? The code that you posted and the answer mentioned above have no difference. You are doing it in perl and the above answer is doing it in shell script. You have also mentioned in your question that you don't require a pipeline answer... Wonder why this simple reply should be the answer though
@Ajai You are right but for some reason the perl script did not produce the desired behavior (i.e. output). I myself do not know why. I am using the shellscript to run format string attacks on a virtual machine running old versions of everything, this might be the cause.
perl -e 'print <>' ? - note that it will buffer until EOF in stdin.

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.