issue with tee command and a script - linux

im trying to use tee command with rendercheck tests on ubuntu 15.04, tee command works fine with 6 tests of rendercheck for example :
./rendercheck -t fill,dcoords,scoords,mcoords,tscoords,tmcoords | tee summary
but if i added other more , example :
./rendercheck -t fill,dcoords,scoords,mcoords,tscoords,tmcoords,composite | tee summary
the output does not shows in terminal and the file summary does not contain nothing, so im not sure why i have this behavior with tee command, it would be great if someone can help me, thanks

"composite" test opens a graphic window, doesn't display text to standard output.
I guess you'll obtain the same behavior if you just execute:
rendercheck composite | tee summary
Regards

Related

Why am I not able to use -o or --format with ps command to control the output format?

I want to print certain columns only from ps output that is PID, PPID, command, memory utilization and CPU utilization columns.
when I run ps command I get the following output.
Now I only want some columns from this output so I use -o flag as mentioned in this tutorial.
But I am getting this error.
I don't understand where is the problem. I have also tried usin --help and it is not showing -o flag. So I am confused here.
I am using the windows operating system. And using Git Bash terminal to run all these Linux commands.
Git Bash is a terminal for Windows that emulates the Linux bash (shell) functionality. It is not 100% compatible to a "real" bash shell. As you've empirically seen, its ps executable doesn't support all the flags you're used to from Linux. The --help option will show you what flags are supported.
Hello
Maybe put 2 things together, ps and grep? Then try this...
ps | grep -o -E "^[ 0-9]{1,9}"
...and is this working on your system?
( The Space in [ ] is important )

bash redirect output to file but result is incomplete

The question of redirecting output of a command was already asked many times, however I am having a strange behavior. I am using a bash shell (debian) with version
4.3.30(1)-release and tried to redirect output to a file, however not everything are logged in the file.
The bin file that I tries to run is sauce-connectv4.4.1 for linux (client of saucelabs that is publicly available in internet)
If I run
#sudo ./bin/sc --doctor
it showed me a complete lines
it prints :
INFO: resolved to '23.42.27.27'
INFO: resolving 'g2.symcb.com' using
DNS server '10.0.0.5'...
(followed by other line)
INFO: 'google.com' is not in hosts file
INFO: URL https://google.com can be reached
However, if I redirect the same command to a file with the following command
#sudo ./bin/sc --doctor > alloutput.txt 2>&1
and do
#cat alloutput.txt
the same command output is logged, but deprecated as following:
INFO: resolved to '23.42.2me#mymachine:/opt/$
It has incomplete line, and the next lines that follows are not even logged (missing).
I have tried with >> for appending, it has the same problem. Using command &> alloutput.txt also is not printing the whole stuff. Can anyone point out how to get all lines of the above command to be logged completely to the text file?
UPDATE
In the end I manage to use the native binary logging by using --log
alloutput.txt where it completely provide me with the correct output.
However I let this issue open as I am still wondering why one misses some information/lines by doing an output redirection
you should try this: stdbuf -o0
like:
stdbuf -o0 ./bin/sc --doctor 2>&1 | tee -a alloutput.txt
That is a funny problem, I've never seen that happening before. I am going to go out on a limb here and suggest this, see how it works:
sudo ./bin/sc --doctor 2>&1 | tee -a alloutput.txt
#commandtorun &> alloutput.txt
This command will redirects both the error and output to same file.

'top -p PID -n1' not working as cronjob

With totem playing a video, running top -p $(pidof totem) -n1 from the terminal works perfectly. Extending it slightly to top -p $(pidof totem) -n1 > ~/test.txt and running it as a once-per-minute cronjob, test.txt is written to, but produces a blank document. There are no errors being produced, or at least nothing is listed in the log files, and Cron doesn't send any mail alerts indicating a problem either. I have no problem getting Cron to run other scripts.
The same thing occurs with all 3 Linux distros I have - Mint 17.2, Deepin 2014, and Ubuntu 10.04.
I have found posts from several people who have encountered the same problem, but unfortunately none of the below suggestions they received work for me;
adding the following;
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
export DISPLAY=:0.0
or any of the following;
export TERM=xterm
top -bn1 | head
TERM=dumb top -n1 | head
TERM=xterm top -n1 | head
At this stage, I'm beginning to think that it's top itself that's buggy. After spending many hours working on a Bash script that's based around top -p, it's pretty demoralising to discover that once done, I now can't get it to run as a cronjob.
Can anyone offer any suggestions as to what the problem might be?
Edit: I'm a mite embarrassed to admit that top -p PID -bn1 | head does work after all! I must have mistyped or something when I tried it first time around! Nevermind, hope it's of help to someone in the future.

How to redirect output of cu to a file ?

I am using cu utility to connect my Cubieboard 1 with my laptop. As I boot my Cubieboard , it sends the boot log to my terminal.
What I want is that the output should be displayed to my screen as well as be sent to some log file which I specify.
I can't find any option to do the same. Any ideas on how I could do that ?
Alternatively, if standard error should be in the file
<command> 2>&1 | tee log.txt
or
<command> |& log.txt
You could pipe into tee. You should then see output on screen and logged to a file of your choice.
<command> | tee log.txt

Redirect output of Whatsapp bash script to file interactively for automation purpose

Yowsup-cli is a library that can allow you to send message to whatsapp users,once authenticated.
By the coommand
yowsup-cli -a --interactive <PHONE_NUMBER_HERE> --wait --autoack --keepalive --config yowsup-master/src/yowsup-cli.config
I can interactively send or receive messages.
Once executed the command you get a prompt like
MY_PHONE_NUMBER#s.whatsapp.net [27-12-2014 18:33]:THIS IS MY MESSAGE,TYPED ON MY PHONE. OPEN DOOR GARAGE
Enter Message or command: (/available, /lastseen, /unavailable)
I'm a totally beginner, but I would like to redirect this content that gets printed on terminal to a file,to further analyze it or to write a script that search into this file keyword as "OPEN GARAGE DOOR", so i could automate something.
This file obviously has to sync with the program output,but I don't know how to do.
yowsup-cli -a --interactive <PHONE_NUMBER_HERE> --wait --autoack --keepalive --config yowsup-master/src/yowsup-cli.config > /path/to/my_file
doesn't work
Running Ubuntu 12.04.
I know yowsup is a python library, but i don't know this language. I'm beginning learniing C and I would like to do that in BASH, or if not possible in C.
Thanks
Pipe the output into tee instead of redirecting it into a file:
yowsup-cli -a --interactive <PHONE_NUMBER_HERE> --wait --autoack --keepalive --config yowsup-master/src/yowsup-cli.config 2>&1 | tee -a /path/to/my_file
The reason: With redirection you don't see the command's output which makes interacting with it hard.
Piping into the tee command will echo all output the the terminal and append it to given file.
Interestingly, in your command line (using redirection) you can still type blindly or even according to the yowsup-cli ouptut you read in another terminal with:
tail -f /path/to/my_file
Tail with the -f option prints the last 10 lines of the file as well as any new ouptut from the yowsup-cli command.

Resources