Visit Our UNIX and Linux User Community


Terminal redirection?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Terminal redirection?
# 8  
Old 06-07-2011
Here, I am tracing an xterm running bash to do pwd and to close window:
Code:
$ (
truss -faelo /tmp/bash.tr xterm -e bash -i &
sleep 1
tail +0f /tmp/bash.tr
)
[1]     17913
NOTE: /usr/bin/X11/xterm: losing setuid/setgid privileges when tracing
17925/29482:    execve(0x7b0f5bf0, 0x7b0f54c0, 0x7b0f54d4)    [entry]
                              argv[0] @ 0x7b0f0020: "xterm"
                              argv[1] @ 0x7b0f0026: "-e"
                              argv[2] @ 0x7b0f0029: "bash"
                              argv[3] @ 0x7b0f002e: "-i"
 .
 .
 .
18907/640:      write(2, "$   ", 2)                             = 2
18906/637:      select(7, 0x4000de90, 0x4000de8c, NULL, NULL)   = 1
18907/640:      sigprocmask(SIG_SETMASK, 0x4001a640, NULL)      = 0
18906/637:      read(6, "$   ", 4096)                           = 2
18907/640:      sigsetstatemask(0x17, NULL, 1073852280)         = 0
18906/637:      read(6, 0x4000fb80, 4096)                       = 0
18906/637:      write(5, "L 01\00502\0\01502\0\010\011\01 ".., 60) = 60
18906/637:      select(7, 0x4000de90, 0x4000de8c, NULL, NULL)   [sleeping]
18906/637:      select(7, 0x4000de90, 0x4000de8c, NULL, NULL)   = 1
18906/637:      ioctl(5, FIONREAD, 0x7b0f5ce0)                  = 0
18906/637:      read(5, "\b04\0{ j 85! I \0\0\0& 02\0\00e".., 32) = 32
18906/637:      select(7, 0x4000de90, 0x4000de8c, NULL, NULL)   = 1
18906/637:      ioctl(5, FIONREAD, 0x7b0f5ce0)                  = 0
18906/637:      read(5, "\n03\0{ 02\0\00e0186a2| ffffffff".., 32) = 32
18906/637:      write(5, "L 01\00502\0\01502\0\010\0# \01 ".., 52) = 52
18906/637:      select(7, 0x4000de90, 0x4000de8c, NULL, NULL)   = 1
18906/637:      ioctl(5, FIONREAD, 0x7b0f5ce0)                  = 0
18906/637:      read(5, "\n03\0{ 02\0\00e030 \ra8j 85! a1".., 32) = 32
18906/637:      write(5, "L 01\00502\0\01502\0\010\0# \01 ".., 52) = 52
18906/637:      select(7, 0x4000de90, 0x4000de8c, NULL, NULL)   = 1
18906/637:      ioctl(5, FIONREAD, 0x7b0f5ce0)                  = 0
18906/637:      read(5, "\t03\07f02\0\00e03a e6@ U U U U ".., 32) = 32
18906/637:      write(5, "L 01\00502\0\01502\0\013\0# \01 ".., 20) = 20
18906/637:      select(7, 0x4000de90, 0x4000de8c, NULL, NULL)   = 1
18906/637:      ioctl(5, FIONREAD, 0x7b0f5ce0)                  = 0
18906/637:      read(5, "\t03\07f02\0\00e02a e6@ U U U U ".., 32) = 32
18906/637:      write(5, "L 01\00502\0\01502\0\013\0# \01 ".., 20) = 20
18906/637:      select(7, 0x4000de90, 0x4000de8c, NULL, NULL)   = 1
18906/637:      ioctl(5, FIONREAD, 0x7b0f5ce0)                  = 0
18906/637:      read(5, "a1  \08002\0\00e\0\0\0x \0\0\0y ".., 32) = 32
18906/637:      writev(5, 0x7b0f6008, 3)                        = 16
18906/637:      read(5, "01\0\082\0\0\0\0\0\0019f\0\t' bc".., 32) = 32
18906/637:      writev(5, 0x7b0f6008, 3)                        = 24
18906/637:      read(5, "01\0\083\0\0\0\0\0\001a0\0\t' bb".., 32) = 32
18906/637:      writev(5, 0x7b0f6008, 3)                        = 24
18906/637:      read(5, "01\0\084\0\0\0\0\0\001a1\0\t' bb".., 32) = 32
18906/637:      writev(5, 0x7b0f6008, 2)                        = 24
18906/637:      read(5, "01\0\085\0\0\0\0\0\001a2\0\t' bb".., 32) = 32
18907/640:        Received signal 1, SIGHUP, in read(), [caught], no siginfo
18906/637:      kill(-18907, SIGHUP)                            = 0
18907/640:      read(0, 0x7b0f673c, 1)                          = 0
18907/640:      stat64("/dhome1/n/myid/.sh_history", 0x7b0f6e38) = 0
18907/640:      open("/dhome1/n/myid/.sh_history", O_WRONLY|O_APPEND|O_LARGEFILE, 0600) = 6
18907/640:      write(6, "p w d \n", 4)                         = 4
18907/640:      close(6)                                        = 0
18907/640:      open("/dhome1/n/myid/.sh_history", O_RDONLY|O_LARGEFILE, 0666) = 6
18907/640:      fstat64(6, 0x7b0f6ef0)                          = 0
18907/640:      sigprocmask(SIG_BLOCK, 0x7b0f70ac, 0x7b0f70cc)  = 0
18907/640:      brk(0x40266000)                                 = 0
18907/640:      sigprocmask(SIG_SETMASK, 0x7b0f70cc, NULL)      = 0
18907/640:      read(6, "0101r e = ' ( < n a m e > ) ( ? ".., 392008) = 392008
18907/640:      close(6)                                        = 0
18907/640:      brk(0x401e6000)                                 = 0
18907/640:      sigprocmask(SIG_BLOCK, 0x7b0f6e68, 0x7b0f6e88)  = 0
18907/640:      ioctl(255, TIOCSPGRP, 0x7b0f6eb8)               = 0
18907/640:      sigprocmask(SIG_SETMASK, 0x7b0f6e88, NULL)      = 0
18907/640:      setpgid(18907, 18907)                           ERR#1 EPERM
18907/640:      sigaction(SIGHUP, 0x7b0f6e20, 0x7b0f6e48)       = 0
18907/640:      getpid()                                        = 18907 (18906)
18907/640:      kill(18907, SIGHUP)                             = 0
18907/640:        Received signal 1, SIGHUP, in kill(), [SIG_DFL], no siginfo
18907/640:      kill(0, 0x447)                                  [entry]
18907/640:      exit(1) [implicit (kill failure)]               WIFSIGNALED(SIGHUP)
18906/637:        Received signal 18, SIGCLD, in select(), [caught], no siginfo
18906/637:      select(7, 0x4000de90, 0x4000de8c, NULL, NULL)   = 0
18906/637:      waitpid(-1, NULL, WNOHANG)                      = 18907
18906/637:      kill(-18907, SIGHUP)                            ERR#3 ESRCH
18906/637:      open("/etc/utmp", O_RDWR|O_CREAT, 0644)         ERR#13 EACCES
18906/637:      open("/etc/utmp", O_RDONLY, 0124730)            = 7
18906/637:      read(7, "\0\0\0\0\0\0\0\0\0\0\0\0s y s t ".., 60) = 60
18906/637:      read(7, "\0\0\0\0\0\0\0\0\0\0\0\0r u n - ".., 60) = 60
 .
 .
 .
18906/637:      close(7)                                        = 0
18906/637:      close(6)                                        = 0
18906/637:      chown("/dev/ttyp3", 0, 0)                       ERR#1 EPERM
18906/637:      chown("/dev/pty/ttyp3", 0, 0)                   ERR#1 EPERM
18906/637:      chmod("/dev/ttyp3", 0666)                       ERR#1 EPERM
18906/637:      chmod("/dev/pty/ttyp3", 0666)                   ERR#1 EPERM
18906/637:      exit(0)                                         WIFEXITED(0)
$

# 9  
Old 06-07-2011
At first glance I have no idea what to do with this information but I'll do some research and try to find out how I can use it to get the current text from another terminal. Thanks again.
# 10  
Old 06-07-2011
To get full I/O data, you can add '-wall -rall' to truss. It may not be the end solution, but it shows you where the data you want to capture is being written.

It's also very educational about the operation of system calls and the division of functions in UNIX between applications and the kernel, like malloc() become brk() and the synamic linker ld() uses mmap() to map parts of libraries into VM, so all users of these libraries share the same RAM pages.

Previous Thread | Next Thread
Test Your Knowledge in Computers #777
Difficulty: Easy
The Fourier transform can be formally defined as an improper Riemann integral.
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