top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration
Print Preview

Log output of bash script when part is run as different user

+1 vote

I have got a bash script that has two parts.
1. runs a script as a different user (using su -c )
2. when that part finishes, the script does a copy of the files created to another directory
I want to log the output of the entire script into one file. i.e.: internal script>external script> logfile
Whats the best way to do this?

posted Aug 21, 2013 by Abhay Kulkarni

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

1 Answer

+1 vote

Why do you think you need to care about the internal called one? you call whatever and say "redirect my output", that belongs to *anything* called by this script with the only exception of stderr

 command 2>> logfile.txt >> logfile.txt
answer Aug 21, 2013 by Mandeep Sehgal
Similar Questions
0 votes

Here, I want to filter some specific files and directories.

0 votes

Have the following in xfce autostart:

# Disable screensaver and dpms emergy star.
export DISPLAY :0.0 
xset s off && 
xset -dpms 

on running:

./xset: line 4: export: `:0.0': not a valid identifier

It appears to be the correct display going by:

+1 vote

I am trying to understand how to use named pipes in python to launch external processes (in a Linux environment).

As an example I am trying to "imitate" the behaviour of the following sets of commands is bash:

> mkfifo named_pipe
> ls -lah > named_pipe &
> cat < named_pipe

In Python I have tried the following commands:

import os
import subprocess as sp

os.mkfifo("named_pipe",0777) #equivalent to mkfifo in bash..
fw = open("named_pipe",'w')
#at this point the system hangs...

My idea it was to use subprocess.Popen and redirect stdout to fw... next open named_pipe for reading and giving it as input to cat (still using Popen).

I know it is a simple (and rather stupid) example, but I can't manage to make it work..

How would you implement such simple scenario?

+1 vote

I have a script-service running on a remote server, listening on a specific port. What i need here is to make this also maintain a log file of ALL incoming connections.

Could someone suggest to me a simple codefunction example to implement that on my main running service?

Useful Links with Similar Problem
Contact Us
+91 9880187415
#470/147, 3rd Floor, 5th Main,
HSR Layout Sector 7,
Bangalore - 560102,
Karnataka INDIA.