Downloading files with today's date only from SFTP server with WinSCP - scripting

I am trying to only download files that are created today, just like tomorrow I would only want to download files created tomorrow only. Essentially I log into the remote server with my script and download all the files right now with synchronize local. What I want to do is just only download the files created today. Right now I just added the filemask and I am still getting all of the files however I only want today's files.
open sftp://location.net -passphrase="passphrase" -hostkey="key"
synchronize local C:\Users\localdrive\Desktop\test2 /Home/remoteFolder/
exit
I also tried
get /Home/remoteFolder/ -filemask=*>1D
and it hasn't changed anything.
Any suggestions would be great.

Use a file mask with a time constraint and the today keyword to create the today's constraint.
get -filemask=">=today" /remote/path/* C:\local\path\
(You need WinSCP 5.15 or newer for the today keyword)
Your *>1D file mask downloads files created/modified in the last 24 hours, so not only today's files.
Further reading:
Question WinSCP time based file download,
WinSCP article on Downloading the most recent file.

Related

openvms create file without version extension (;1,etc)

Does anybody know how can I create a text file in OpenVMS without the version extension? I need to take some logs from this server and edit them in a Linux server. Until know the downloaded file from OpenVMS server cannot be opened.
Regards,
Theodore
Did you google your problem? You would find answers to help you along.
As indicated you cannot get rid of the file version number on the OpenVMS side.
You can edit those file on the Linux side easily - folks do it all the time.
You indicate the file cannot be opened. What is the error message?
Best is to copy&paste the exact command used and the returned message.
On Linux You probably just need to escape the ";" with a backslash to avoid it from terminating the command fragment. Or you can put the whole name in quotes.
If you don't like that, then you may need to look at the tool used to access (Samba?), package (zip?) or transfer the file (ftp/sftp). They are likely to have a setting to honor or discard the file version.
Since you fail to indicated exactly what you are doign, we cannot help until we know.
The ZIP on my OpenVMS server has options -
zip -h
Info-ZIP - Zip 3.0 (July 5th 2008).
-w store file version numbers -ww store file version numbers as ".nnn"
Good luck!
Hein

AMPPS - The file /Applications/AMPPS/ampps/softaculous/includes/enduser.php is corrupted

I've had this issue twice now, just randomly happened.
When I try to view the Ammps 'Home' Dashboard I get the following error:-
The file /Applications/AMPPS/ampps/softaculous/includes/enduser.php is
corrupted.
I had to re-install to fix this last time but since then (a few days ago) this has happened again?
Anybody know why this is happening and how to fix it?
I am using Version: 3.8
Update
I've done another clean install (backed up www and all the databases beforehand). I noticed there isn't even the directory /Applications/AMPPS/ampps/softaculous/includes/.
Seems to be another effected file as well:
/Applications/AMPPS/ampps/softaculous/includes/main/functions.php is
corrupted.
Upon opening these files, it appears a massively long string of characters as been added after the closing PHP tag. Deleting this string had no effect, the same errors persist.
Anyway, I've uploaded the files of Ampps for Mac which you can download here:
https://drive.google.com/file/d/18nA-ldR5BamLLqnEU0nC4Gx-PmzWSwt0/view?usp=sharing
Going to see if I can get it back working once I merge the files together (except the www folder)
Update 2:
You can now download Ampps 3.9 from their official website:
https://ampps.com/download
1.+ don't forget to save database (/var) and domains information (/ampps/data/domains) before replacing files
Doing a clean install of Ampps 3.8 will rectify the problem which is what I had to do. Frustratingly, some people including myself have experienced the issue coming back after a few days. Until there is a permanent fix for this either by an update/patch from Softaculous, a way to rectify this without having to reinstall Ampps is by doing the following:-
Take a backup of your /Applications/AMPPS/www directory
Download the Mac files from a clean installation here;
https://drive.google.com/file/d/18nA-ldR5BamLLqnEU0nC4Gx-PmzWSwt0/view?usp=sharing
Replace the existing Ampps directory with the files from the
download link
Move your /www/ folder back to the same location
You should then be able to access the Home dashboard and everything should work as normal.
As Nika mentioned, don't forget to save database (/var) and domains information (/ampps/data/domains) before replacing files (/www)
Edit 1:
Seems my version of Ampps 3.8 got updated to 3.9, I've not had any issues since this has happened.
Please create a backup first!
Shutdown AMPPS. I have fixed mine locally by replacing the enduser.php with the one from here https://files.ampps.com/5.3.2.zip.
Then after that I have replaced all the IonCube loaders with the ones you can download from here: https://www.ioncube.com/loaders.php. Source and how-to: https://www.softaculous.com/board/index.php?tid=13497&title=Ioncube_Loader_Error
Start AMPPS.
To check if you need to replace another corrupt file check error_log in your logs folder.

How to delete remote file using Kettle Pentaho

I have a directory in remote Linux machine where files are being archived and kept for a certain period of time. I want to delete a file from remote (Linux) machine using kettle transformation based on some condition.
If file does not exists then job should not throw any error but if file exists at remote location, then job should delete file or raise an error in case some other reason, i.e., permission issue.
Here, the file name will be retrieved as a variable from previous steps of transformation and directory path of archived files will be fixed one.
How can I achieve this in Pentaho Kettle transformation?
Make use of "Run SSH commands" utility to pass commands to your remote server.
Assuming you do a rm -f /path/file it won't error for a non-existent file.
You can capture the output and perform an error handling as well (Filter rows and trigger the course of action).
Or you can mount remote directory to machine where kettle is, and try to delete file as regular.
Using ssh, i think, non trivial. It needs a lots of experiments to find out error types, to find way to distinguish errors. It might be and error with ssh connection or error to delete file.

Fully un-installing google cloud sdk

I tried to uninstall google cloud sdk from my computer a long time ago but when ever I login to terminal I get this message:
Last login: Sat Sep 9 12:40:05 on console
You have new mail.
-bash: /Users/me/google-cloud-sdk/path.bash.inc: No such file or directory
-bash: /Users/me/google-cloud-sdk/completion.bash.inc: No such file or directory
ME:~ myshell$
I have tried this answer but the problem is I don't have a google cloud account anymore.
I also reach a dead end on this one as well b/c none of the files or folder seem to exist on my computer.
How do I resolve this?
You will have to edit your .bashrc and remove references to gloud-cloud-sdk look for lines like
source "$CLOUD_SDK/completion.bash.inc"
source "$CLOUD_SDK/paths.bash.inc"
Also, you may want to remove ~/.config/gcloud

Where does Vagrant download its .box files to?

What happens to the .box file after the following command is executed?
vagrant box add lucid32 http://files.vagrantup.com/lucid32.box
I can't find the lucid32.box file on the file system after download has completed.
As mentioned in the docs, boxes are stored at:
Mac OS X and Linux: ~/.vagrant.d/boxes
Windows: C:/Users/USERNAME/.vagrant.d/boxes
On Mac/Linux System, the successfully downloaded boxes are located at:
~/.vagrant.d/boxes
and unsuccessful boxes are located at:
~/.vagrant.d/tmp
On Windows systems it is located under the Users folder:
C:\Users\%userprofile%\.vagrant.d\boxes
Hope this will help. Thanks
To change the Path, you can set a new Path to an Enviroment-Variable named:
VAGRANT_HOME
export VAGRANT_HOME=my/new/path/goes/here/
Thats maybe nice if you want to have those vagrant-Images on another HDD.
More Information here in the Documentations: http://docs.vagrantup.com/v2/other/environmental-variables.html
The actual .box file is deleted by Vagrant once the download and box installation is complete. As mentioned in other answers, whilst downloading, the .box file is stored as:
~/.vagrant.d/tmp/boxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
where the file name is 'box' followed by a 40 byte hexadecimal hash. A temporary file on my system for example, is:
~/.vagrant.d/tmp/boxc74a85fe4af3197a744851517c6af4d4959db77f
As far as I can tell, this file is never saved with a *.box extension, which explains why the searches above failed to locate it. There are two ways to retrieve the actual box file:
Download the .box file from vagrantcloud.com
Find the box you're interested in on the atlas. For example,
https://atlas.hashicorp.com/ubuntu/boxes/trusty64/versions/20150530.0.1
Replace the domain name with vagrantcloud.com. So https://atlas.hashicorp.com/ubuntu/boxes/trusty64/versions/20150530.0.1
becomes https://vagrantcloud.com/ubuntu/boxes/trusty64/versions/20150530.0.1/providers/virtualbox.box.
Add /providers/virtualbox.box to the end of that URL. So https://vagrantcloud.com/ubuntu/boxes/trusty64/versions/20150530.0.1 becomes https://vagrantcloud.com/ubuntu/boxes/trusty64/versions/20150530.0.1/providers/virtualbox.box
Save the .box file
Use the .box as you wish, for example, hosting it yourself and pointing config.vm.box_url to the URL. OR
Get the .box directly from Vagrant
This requires you to modify the ruby source to prevent Vagrant from deleting the box after successful download.
Locate the box_add.rb file in your Vagrant installation directory. On my system it's located at /Applications/Vagrant/embedded/gems/gems/vagrant-1.5.2/lib/vagrant/action/builtin/box_add.rb
Find the box_add function. Within the box_add function, there is a block that reads:
ensure
# Make sure we delete the temporary file after we add it,
# unless we were interrupted, in which case we keep it around
# so we can resume the download later.
if !#download_interrupted
#logger.debug("Deleting temporary box: #{box_url}")
begin
box_url.delete if box_url
rescue Errno::ENOENT
# Not a big deal, the temp file may not actually exist
end
end
Comment this block out.
Add another box using vagrant add box <boxname>.
Wait for it to download.
You can watch it save in the ~/.vagrant.d/tmp/ directory as a boxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX file.
Rename the the file to something more useful. Eg, mv boxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX trusty64.box.
Why would you want this?
For me, this has been useful to retrieve the .box file so it can be hosted on local, fast infrastructure as opposed to downloading from HashiCorp's Atlas box catalog or another box provider.
This really should be part of the default Vagrant functionality as it has a very definitive use case.
#Luke Peterson: There's a simpler way to get .box file.
Just go to https://atlas.hashicorp.com/boxes/search, search for the box you'd like to download. Notice the URL of the box, e.g:
https://atlas.hashicorp.com/ubuntu/boxes/trusty64/versions/20150530.0.1
Then you can download this box using URL like this:
https://vagrantcloud.com/ubuntu/boxes/trusty64/versions/20150530.0.1/providers/virtualbox.box
I tried and successfully download all the boxes I need. Hope that help.
On Windows, the location can be found here. I didn't find any documentation on the internet for this, and this wasn't immediately obvious to me:
C:\Users\\{username}\\.vagrant.d\boxes
In addition to
Mac:
~/.vagrant.d/
Windows:
C:\Users\%userprofile%\.vagrant.d\boxes
You have to delete the files in VirtualBox/OtherVMprovider to make a clean start.
On Windows 10 with Vagrant 2.2.2, setting the environment variable VAGRANT_HOME will ensure that boxes are downloaded to a subfolder of the folder specified for VAGRANT_HOME.
In my case I set VAGRANT_HOME to e:\vagrant_home, and the boxes get stored under e:\vagrant_home\boxes.
This works for me.
That's where the boxes are stored. The virtual machines are being created in the folder configured in Virtual Box. To set the VirtualBox VM storage folder, go to: VirtualBox GUI --> File --> Preferences --> General --> Default Machine Folder.