How to fetch an Artisan Command output(file) into a variable? - laravel-5.4

I have a method(export) which calls an Artisan command, which exports the database and stores a .sql file into the system.
public function export() {
$export = Artisan::call('backup:mysql-dump');
}
so what I need to do is, I need to grab the .sql file (or its location and name) which was created by the Artisan command and pass it to another method as a variable. The idea is to grab that file and use it as an attachment in an email, without having to do it manually.

Related

Self hosted Github runner does not load env variables from .zshrc

When I'm trying to run an action via Github with my self hosted runner it is not possible to load the environment variables from my .zshrc file (e.g. the PATH)
When I'm executing "printenv" I will get e.g for PATH:
PATH=/usr/bin:/bin:/usr/sbin:/sbin
but it should be:
PATH=/Users/jenkins/.rbenv/shims:/opt/homebrew/opt/openjdk/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/jenkins/.rbenv/shims:/opt/homebrew/opt/openjdk/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/bin:/bin:/usr/sbin:/sbin
It is only possible when I call source ~/.zshrc before the printenv.
Is it possible to open the shell directly with the zshrc env variables without sourcing it manually?

SSIS Download the files using FTP Task inside the For Each loop by passing the Variable Enumerator

Download the files using FTP Task inside the For Each loop by passing the Variable Enumerator to set the Remote Path Variable
I am loading the list of files to download in a variable.( Verified and I can see the list of files)
Using the ForEach loop container I am receiving the file names using the Variable Enumator and passing it to the FTP Task inside the ForEach loop. (Verified and I can see the filenames one by one)
In the FTP Task when I try to set the remote path variable as the file name from the for each loop it is showing the error
FTP task variable does not begin with '/' error
When I manually set the Remote Path with the "/" + User::fileName during the run time I am getting an error message "Path is not of a legal form"
In the SSIS FTP task set the delay validation to true in the properties. which will validate the Remote Path during the run time and it will resolve setting the remote path value from variable.

What is the command to generate migration script from existing sequelize models?

I've created models using the following command.
$ node_modules/.bin/sequelize model:create --name XYZ --attributes "....."
But by mistake I deleted the folder containing migration script. Now I want to generate this script again.
I tried using sequelize migration:create, but it generated any empty file.
Please Help.
What you need to do now, after you generated a new migration file is to copy the skeleton from here: http://docs.sequelizejs.com/manual/tutorial/migrations.html#skeleton and to customize your migration using the functions that you need.

Get the latest updated file from FTP Folder

Kindly see this screen cast to get better idea about our requirement:
https://www.screenr.com/QmDN
We want to automate the Text Datasource Generation and connection to MS Excel in order to make it easier to the end-user to connect to the Text Datasource (CSV) to MS Excel so that they can generate their own reports.
The steps I have in mind:
Use WinSCP FTP Client with Scripting
Write script to get the most recent updated file from FTP Folder
Or instead of step 2, download all generated files from FTP to a Shared Folder on the Network.
Get the most recent version of the Generated CSV File
Rename the file to the Standard Naming Convention. This must be the name used in MS Excel as the CSV Text Datasource.
Delete all other files
I developed sample script that can be used by WinSCP to download the files from FTP folder:
# Automatically abort script on errors
option batch abort
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect
open CSOD
# Change remote directory
cd /Reports/CAD
# Force binary mode transfer
option transfer binary
# Download file to the local directory d:\
#get "Training Attendance Data - Tarek_22_10_21_2014_05_05.CSV" "D:\MyData\Business\Talent Management System\Reports\WinCSP\"
get "*.CSV" "D:\MyData\Business\Talent Management System\Reports\WinCSP\Files\"
# Disconnect
close
exit
Then, I can schedule the above code to run periodically using this command:
winscp.com /script=example.txt
The above sample is working fine, but the main problem is how to identify the most recent file, so that I can rename it, and delete all the other files.
Appreciate your help.
Tarek
Just add the -latest switch to the get command:
get -latest "*.CSV" "D:\MyData\Business\Talent Management System\Reports\WinCSP\Files\"
For more details, see WinSCP article Downloading the most recent file.
You don't specify the language you use, here a Ruby script that downloads the most recent file of an FTP path. Just to demonstrate how easy and terse this can be done with a scripting language like Ruby.
require 'net/ftp'
Net::FTP.open('url of ftpsite') do |ftp|
ftp.login("username", "password")
path = "/private/transfer/*.*"
# file[55..-1] gives the filename part of the returned string
most_recent_file = ftp.list(path)[2..-1].sort_by {|file|ftp.mtime(file[55..-1])}.reverse.first[55..-1]
puts "downloading #{most_recent_file}"
ftp.getbinaryfile(most_recent_file, File.basename(most_recent_file))
puts "done"
end

Unzip a Password Protected file in SSIS

I have problem with Unzipping a Password Protected file in a SSIS Package.
I Always use Execute Process task But this time After the package download zip file from ftp it must unzip it then i use it as flat file.
now the problem is i can't unzip the file cause its password protected.i have the password of file but i don't now how to use it.
is there a command line or some thing?
You need to find a command-line tool that can unzip password protected zip files, then you can use the Execute Process task as usual. If you don't want to hard-code the password into the SSIS package, you could put it in a package variable, populate the variable from a package configuration or a dtexec parameter, and then set the properties of the Execute Process task dynamically.
Finally find it...
use a execute process task and set parameter as below:
executable : C:\Program Files\WinRAR\WinRAR.exe.....(winrar location)
Arguments : e -o+ -ppassword "filename"........i.e e -o+ -p12345 "D:\TRFolder\TR0426.zip"
Working Directory : D:\TRFolder ....... UnzipPath
peace
I got it which actually worked for me.
We need to pass some parameter in the Execute Process task Editor
executable: C:\Program Files\7-Zip\7z.exe [ Source where 7z is installed file]
Arguments: here we have to pass source, password (if any) & destination. followed by e(i.e extract)
For example:
e "D:\App\File\TextDoc.7z" -p1234#Abcd -oD:\App\File\Extract * -r
Here
e means extract
Source: D:\App\File\TextDoc.7z
password: 1234#Abcd
Destination: D:\App\File\Extract
r: this is for Read. means the extracted file file will be visible while extracting