Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 08-10-2018, 12:44 PM   #1
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

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

in script i have the following:

#create Ticket for failed backup#
JIRA=`/opt/atlassian-cli/ --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/ --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, 01:21 PM   #2
Senior Member
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.5
Posts: 1,985

Rep: Reputation: 624Reputation: 624Reputation: 624Reputation: 624Reputation: 624Reputation: 624
one way:
pass the name of the log file being created into /usr/local/bin/
/usr/local/bin/ /var/log/backup-`date "+\%m\%d\%y"`.log
then use the $1 parameter in the script for the --file parameter:
... --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)


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

All times are GMT -5. The time now is 02:41 PM.

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