LinuxQuestions.org
Review your favorite Linux distribution.
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 08-10-2018, 11:44 AM   #1
krazykracker
LQ Newbie
 
Registered: May 2016
Posts: 3

Rep: Reputation: Disabled
How to pass in echo of log file creation to pass in to script to attach the file


I have a Cron that is running that at script that backs up data is passing in variables to the backup and create script i need to know how to take the log file im passing and add to the

CRON:
BACKUP=DEV /usr/local/bin/backup.sh > /var/log/backup-`date "+\%m\%d\%y"`.log 2>&1||/usr/local/bin/create-ticket.sh

in script create-ticket.sh i have the following:


#create Ticket for failed backup#
JIRA=`/opt/atlassian-cli/jira.sh --server https://blahblah --user admin --password blahblah --action createIssue --project "DEV" --type "Incident" --summary "Failed backup on $BACKUP" --components "blah" --priority "Major"| awk '{print $2}'`

###Atttach logs:###
/opt/atlassian-cli/jira.sh --server https://blahblah --user admin --password blahblah --action addAttachment --issue "${JIRA}" --file "?????"


I Need to know how to get the file name of this cron output "/var/log/backup-`date "+\%m\%d\%y"`.log" in to the section (--file "????")

i know i can do a Variable=/var/log/backup-`date "+\%m\%d\%y"`.log & pass in $Variable but i don't want to do that.


any help would be appreciated.
 
Old 08-10-2018, 12:21 PM   #2
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.5
Posts: 1,405

Rep: Reputation: 479Reputation: 479Reputation: 479Reputation: 479Reputation: 479
one way:
pass the name of the log file being created into /usr/local/bin/create-ticket.sh
Code:
/usr/local/bin/create-ticket.sh /var/log/backup-`date "+\%m\%d\%y"`.log
then use the $1 parameter in the create-ticket.sh script for the --file parameter:
Code:
... --file "$1"
I realize that's similar to the thing you don't want to do, and if the backup runs just before midnight and the create-ticket just after midnight the date command would return different dates.

Why don't you want to use a variable to hold the log file name? (It would still have to be passed in as above unless exported)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] Pass a script line to a file rockie321 Linux - Newbie 11 02-24-2012 10:52 AM
grep multiple values in single pass through log file. 1ankit1 Programming 2 11-13-2010 04:45 PM
[SOLVED] pass source file into awk script vinaytp Linux - Newbie 11 07-15-2010 03:38 AM
Need help writing Unix Shell script to pass file name,path,creation date ! windjashi Programming 4 10-08-2009 12:59 AM
Pass the contents of firewall log to another file arubala1 Linux - Networking 2 03-16-2006 03:50 AM

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

All times are GMT -5. The time now is 10:28 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration