Execute a script and not able to redirect to a file
Hi,
I am trying to execute a script. This scripts waits for commands from another console. I want to capture everything that will happen from this script. I am using the following: ./script >> log.txt cat log.txt log.txt is empty. If I use something like this: ps >> log.txt , it works. Thanks! |
What's the contents of script?
|
The script's function is to execute abc.out. To simplify, abc.out has a bunch of questions and the user has to answer it.
Contents of the script: pidof abc.out | xargs kill (find the pid and kill the process) /programs/abc.out The function of abc.out is: abc.out asks the user many questions and the user replies to it. abc.out waits for the inputs from the user. If the script is to execute many commands without any user interaction the redirection to the file works but if its the case like above, the redirected file is empty. Thanks! P.S: Since I use Busybox, and there is no pidof, I somehow managed to do the equivalent of pid. |
You could probably combine all of this into one script, if abc.out is also a script...
You could run something like this as a script maybe: Code:
#!/bin/bash |
Hi Casualfred,
Thanks for your input. But abc.out does a lot more than just simple questions. It communicates between another console where it gets the input. So this has to be run by another script. And when I run this script I need to capture all the input/output from abc.out to a log file. Hence my question. Thanks! |
Does it work if you run it directly?
Code:
/programs/abc.out >> log.txt |
No it doesn't. It's still the same issue. The script is just to kill the process before executing it.
|
Quote:
Try Code:
/programs/abc.out >> log.txt 2>&1 |
Or it doesn't create an output at all. Perhaps the application only creates an output on virtual terminals just for the sake of interaction. It doesn't open anything like files if it's not.
|
I tried the same but it doesn't work :(
Quote:
|
When I use the following:
Code:
./script & >> log.txt Code:
[1] + Done ./script |
Quote:
|
No I just wanted atleast the script to run while having the ">>" in my command. But I don't want it to run in the background.
Also, my task can also be implemented if I could capture everything that is going to happen right from logging into the console. Is there anyway to capture everything from log on. I will be continuously monitoring the log so that once I find a regex match I will have to run the script again. That has been my aim. Thanks ! |
Quote:
|
Busybox that I use doesn't support vim.
|
All times are GMT -5. The time now is 09:40 AM. |