Visit Our UNIX and Linux User Community


Terminal redirection?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Terminal redirection?
# 1  
Old 06-06-2011
Terminal redirection?

Hi, I'm working on my first real shell script and I've hit a wall. My script opens commands in new terminal windows like this..

gnome-terminal -x bash -l -c "ls -l; bash"

My question is, how can I get the information that command outputs? I know how to redirect output to a file with > or even | tee but my problem is with terminals that are running commands that keep going. The output files just seem to stay empty. I was looking for some sort of way to pipe the output back to my script but I don't even know if that can be done. Anyhow, I hope this was clear enough for someone smarter than me to understand haha.
# 2  
Old 06-06-2011
Well, there are sorts of solutions in expect, screens, ssh. I logged in program may write the terminal with stdout (buffered), stderr (unbuffered) or /dev/tty (the terminal, not usually redirected). You want to capture the output on the latter. Sometimes it is easier to put the app data on a log file and then 'tail +0f' the log file to the screen.
# 3  
Old 06-06-2011
I would be happy to redirect it to a file but it doesn't seem to work when the program being run has to update data in the terminal output. Works fine for anything that just outputs it's data and ends though.
# 4  
Old 06-06-2011
Well, if it is addressing the screen, that is tough to map to a file. Bash does the occasional backspace or carriage return to move the cursor, but that can be recorded even if it is hard to present. What are you trying to log?
# 5  
Old 06-06-2011
It's nothing specific yet but what I've been using for testing is just a little program that that has a list of the last 10 coordinates returned by a GPS. instead of just scrolling the list it moves everything up 1 when it adds a new one to the list. as far as I can tell that's why it's not working the same.
# 6  
Old 06-06-2011
You can use truss/tusc/strace to see what it calls to write the data, and what data it is writing.
# 7  
Old 06-06-2011
Is there an easy sample you can post here or is it something I should just go and do some research on? Thanks for the help by the way.

Previous Thread | Next Thread
Test Your Knowledge in Computers #829
Difficulty: Medium
The JSON standard supports object references.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print Terminal Output Exactly how it Appears in the Terminal to a New Text File

Hello All, I have a text file containing output from a command that contains lots of escape/control characters that when viewed using vi or view, looks like jibberish. But when viewed using the cat command the output is formatted properly. Is there any way to take the output from the cat... (7 Replies)
Discussion started by: mrm5102
7 Replies

2. Shell Programming and Scripting

Cannot get terminal application to launch with a graphical launcher when successful in terminal

I have been having an extremely annoying problem. For the record, I am relatively new at this. I've only been working with unix-based OS's for roughly two years, mostly Xubuntu and some Kali. I am pretty familiar with the BASH language, as that's the default shell for debian. Now, I've made this... (16 Replies)
Discussion started by: Huitzilopochtli
16 Replies

3. UNIX for Dummies Questions & Answers

A terminal controlling a terminal...

Hi all... Consider me a dummy here... I do not want any code or for anyone to show me how to do it at this time, but here is the question:- I have had this brainstorm to be able to control the AudioScope.sh program in the "Shell Scripting And Programming" forum... Is it possible, by... (4 Replies)
Discussion started by: wisecracker
4 Replies

4. UNIX for Dummies Questions & Answers

Does DOS has a terminal or pseudo terminal?

I am wondering if the DOS console works like the unix terminal? (1 Reply)
Discussion started by: vistastar
1 Replies

5. Shell Programming and Scripting

I/O redirection

Hello everyone,I'm reading a book and there's code fragment: exec 3>&1 ls -l 2>&1 >&3 3>&- | grep bad 3>&- exec 3>&- It says that the red part of that code does not close fd 3 but the green does close the fd 3.I can't understand that.....Why?Any predicate will be appreciated.:) (18 Replies)
Discussion started by: homeboy
18 Replies

6. UNIX for Dummies Questions & Answers

Help with Redirection

Hi Guys, I m new to UNIX and new to this forum. Was wondering if someone can help me understand redirection (standard input output pipeline etc) for starters, not too sure what this would mean who | sort > sortedfile | pr | lp im starting to understand common commands but when throwing... (2 Replies)
Discussion started by: jmack123
2 Replies

7. UNIX for Dummies Questions & Answers

Gnuplot wxt terminal vs x11 terminal

Hi, I installed ubuntu recently on my pc. And I installed gnuplot as well. When I first started working with gnuplot it was working . I did a plot and when I wanted to fit my data something happened and not the default terminal of gnuplot is xwt! I changed it to: set terminal x11, but it... (0 Replies)
Discussion started by: cosmologist
0 Replies

8. UNIX for Advanced & Expert Users

Pseudo-terminal will not be allocated because stdin is not a terminal.

I am trying to automate a SSH login using Keys using the following command ssh -i id_rsa usernamw@ipaddr. I am successful in doing this and i am getting the Warning Screen and I logon successfully. but when I am executing the command tail -1cf put.dat | ssh -i id_rsa username@ipaddr > get.dat ... (1 Reply)
Discussion started by: Shivdatta
1 Replies

9. Programming

Help with redirection

Here is my problem. I don't know make this redirection thing work. The output file (called output.c) looks like this #include<stdio.h> int main() { int k; int m; print f("%d\n", k); printf("%d\n", m); return 0; } the input file(called input.c) is this #include<stdio.h> int... (2 Replies)
Discussion started by: Shallon1
2 Replies

10. UNIX for Advanced & Expert Users

connecting to unix through hyper terminal - as a dumb terminal

I just changed from windows NT to XP and I am no longer able to connect to my unix system. I used to use hyper terminal -- which acts as dumb terminal to my main frame unix system. I think one of the options used to be "direct to comX". This option isn't listed now. I use a serial port and the... (2 Replies)
Discussion started by: michelle
2 Replies

Featured Tech Videos