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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Okay, I wasn't sure if that would work or not since I was running the internal script as a different user.  Thanks.



On Wed, Aug 21, 2013 at 10:11 AM, Reindl Harald <h.reindl@xxxxxxxxxxxxx> wrote:


Am 21.08.2013 16:04, schrieb Mark Haney:
> I've got a bash script that has two parts.
>
> 1. runs a script as a different user (using su <username> -c <script>)
> 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
>
> What's the best way to do this?  I can clarify, I hope, I've edited this a dozen times to get what I want in as
> clear a message as possible

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

command 2>> logfile.txt >> logfile.txt

>> is "do not make the file empty, add your output at the end"
> would empty any existing file before
___________________________________________

[harry@rh:~/Desktop/test]$ cat script1.sh
#!/usr/bin/bash
echo "OUTPUT SCRIPT 1"
bash ./script2.sh

[harry@rh:~/Desktop/test]$ cat script2.sh
#!/usr/bin/bash
echo "OUTPUT SCRIPT 2"

[harry@rh:~/Desktop/test]$ ./script1.sh
OUTPUT SCRIPT 1
OUTPUT SCRIPT 2

[harry@rh:~/Desktop/test]$ ./script1.sh > output.txt

[harry@rh:~/Desktop/test]$ cat output.txt
OUTPUT SCRIPT 1
OUTPUT SCRIPT 2




--
Caesar si viveret, ad remum dareris.

Mark Haney
Software Developer/Consultant
mark.haney@xxxxxxxxx
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux