I will first write a sequence of commands which I want to run
echo <some_input> | <some_command> > temp.dat & pid=$!
sleep 5
kill -INT "$pid"
The above is working perfectly fine when i run it one by one from bash shell, and the contents in the temp.dat file is exactly what I want. But, when I create a bash script containing the same set of commands, I am getting nothing in the temp.dat file.
Now, I'll mention why I'm writing those commands in such a way:
- <some_command> asks for an input, that's why I'm piping <some_input>
- I want the output of that command in a separate file, that's why I've redirected the output.
- I want to kill the command by sending SIGINTsignal after some time.
I've tried running an interactive shell by writing #!/bin/bash -i in the first line of the shell script, but it's not working.
Any alternate method to achieve the same results will be appreciated.
- Update: <some_command>is also invoking a python script, but I don't think that this will cause it to behave differently.
- Update2: python script was the only cause of that different behavior.
 
     
    