Unix/Linux Go Back    


Homework & Coursework Questions Students must use and complete the template provided. If you don't, your post may be deleted! Special homework rules apply here.

How to write logs to new folder?

Homework & Coursework Questions


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 09-29-2015   -   Original Discussion by dsreddy447
dsreddy447 dsreddy447 is offline
Registered User
 
Join Date: Sep 2015
Last Activity: 28 June 2016, 11:12 AM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Display How to write logs to new folder?

Hi the below is my code and my requirement is

a. Whenever below scripts run – logs should be redirected to a new log file in /u/file/newlog folder. Please let me know how to write this info


Code:
#!/bin/ksh
choice=$1
browcher=$2
ne=$3
Flow=$4
logFile=~mbadm/redeploy.log
case "$choice" in
        "deploy")
                barFile=$4
                Flow=`echo $Flow|sed 's/.bar//'`
                #FlowName=`mqsireadbar -b $barFile|grep -E 'cmf|xsdzip|dictionary'|awk '{print $1}'|sed 's/.cmf//'`
                flag=`mqsilist $browcher -e $eg|grep $Flow|wc -l`
                echo `date` >> $logFile
                if [ flag -eq 1 ]; then
                        mqsideploy $browcher -e $ne -a $barFile >> $logFile
                else
                        echo "Flow not already deployed."       >> $logFile
                fi
                ;;
        "stop")
                echo `date` >> $logFile
                mqsistopmsgflow $browcher -e $ne -m $Flow >> $logFile
                ;;
        "start")
                echo `date` >> $logFile
                mqsistartmsgflow $browcher -e $ne -m $Flow >> $logFile
                ;;
        *)
                echo "Invalid option. Valid options are: deploy,stop,start."
esac


Last edited by Corona688; 09-29-2015 at 12:17 PM..
Sponsored Links
    #2  
Old Unix and Linux 09-29-2015   -   Original Discussion by dsreddy447
sea sea is offline
Registered User
 
Join Date: Sep 2013
Last Activity: 14 October 2016, 2:49 PM EDT
Location: Swissh
Posts: 1,285
Thanks: 256
Thanked 226 Times in 209 Posts
Hello and welcome to the forums.
Please use code tags as required (and accepted by you) by the forum rules.

Also, please follow the guide: https://www.unix.com/homework-coursew...ons-forum.html

Thank you
(edit: just seeing its ksh, so me out after this post)
Sponsored Links
    #3  
Old Unix and Linux 09-29-2015   -   Original Discussion by dsreddy447
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 17 November 2017, 6:42 AM EST
Location: Aachen, Germany
Posts: 11,616
Thanks: 320
Thanked 3,615 Times in 3,320 Posts
Try
Code:
logFile=/u/file/newlog/redeploy$(date +"%Y%m%d%H%M%S").log

    #4  
Old Unix and Linux 09-29-2015   -   Original Discussion by dsreddy447
dsreddy447 dsreddy447 is offline
Registered User
 
Join Date: Sep 2015
Last Activity: 28 June 2016, 11:12 AM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
where to place this file

Hi RUDIC,

you mean to say instead of

logFile=~wmqiadm/redeploy.log you want me to replace it with this file

logFile=/u/file/newlog/redeploy$(date +"%Y%m%d%H%M%S").log
Sponsored Links
    #5  
Old Unix and Linux 09-29-2015   -   Original Discussion by dsreddy447
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 17 November 2017, 6:42 AM EST
Location: Aachen, Germany
Posts: 11,616
Thanks: 320
Thanked 3,615 Times in 3,320 Posts
Yes, exactly. That would create a new log file with an individual file name.
Sponsored Links
    #6  
Old Unix and Linux 09-29-2015   -   Original Discussion by dsreddy447
sea sea is offline
Registered User
 
Join Date: Sep 2013
Last Activity: 14 October 2016, 2:49 PM EDT
Location: Swissh
Posts: 1,285
Thanks: 256
Thanked 226 Times in 209 Posts
Uhm guysRudi...
Its homework and missing quite a bunch of information.

Last edited by sea; 09-29-2015 at 12:22 PM.. Reason: should have been private in this case, sorry
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need help to write a script for moving the log files to some other folder natraj005 Shell Programming and Scripting 4 09-20-2011 10:38 AM
write shell script to search file in folder shubhig15 Shell Programming and Scripting 1 12-02-2010 10:21 AM
How to write logs to a specified Directory?? nirmal84 Shell Programming and Scripting 1 02-20-2009 07:24 PM
i want to write a script to test the folder permissions rajesh212512 Shell Programming and Scripting 4 07-11-2008 02:14 PM
to write the logs of scp gholdbhurg Shell Programming and Scripting 1 10-08-2007 10:52 AM



All times are GMT -4. The time now is 09:02 PM.