LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-23-2019, 01:15 PM   #1
pedropt
Member
 
Registered: Aug 2014
Distribution: Devuan
Posts: 345

Rep: Reputation: Disabled
Setsid execute on another tty and log the output


i have been trying to figure why i can not get an output log from another terminal when i launch some script with its output to a file .

when i :

Quote:
setsid sh -c "exec somecommand > log <> /dev/tty9 >&0 2>&1" &
i get the tty opened with the command , but i am unable to get anything on the log file .

even if i :

Quote:
setsid sh -c "exec somecommand | tee log <> /dev/tty9 >&0 2>&1" &
i still can not get the log file from that command .

What happens is that log file is created but it is empty

I am launching setsid from another script , so that is why i have the switch "-c" .

Last edited by pedropt; 11-23-2019 at 01:16 PM.
 
Old 11-23-2019, 01:32 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,869
Blog Entries: 1

Rep: Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870
Perhaps you want sg like this:
Code:
trap '' HUP
command 2>&1 | tee logfile >/dev/tty9
 
Old 11-23-2019, 02:05 PM   #3
pedropt
Member
 
Registered: Aug 2014
Distribution: Devuan
Posts: 345

Original Poster
Rep: Reputation: Disabled
nop , i still need the current master script running while tty9 is opened .
that command you wrote is good for this example :
Quote:
trap '' HUP
ls / 2>&1 | tee logfile >/dev/tty9
but if i need to run netcat on tty9 that will need additional commands then i am stuck .
 
Old 11-23-2019, 02:41 PM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,869
Blog Entries: 1

Rep: Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870
That's what an &ampersand is good for.
Also there is command openvt:
Code:
openvt -- sh -c 'command | tee logfile’
https://linux.die.net/man/1/openvt

Last edited by NevemTeve; 11-23-2019 at 02:44 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Work with setsid to open a session and close it correctly ASF Studio Linux - Newbie 1 12-11-2016 03:48 PM
How to reset/restart a tty from another tty? armandino Linux - General 4 02-25-2009 03:09 AM
can a tty execute command on another tty? BeacoN Linux - Desktop 3 11-08-2008 09:39 AM
setsid and command-line piping in bash ta0kira Programming 7 04-28-2008 09:31 PM
setsid() question: child has terminal after all? registering Programming 1 06-16-2003 06:50 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration