FTP Batch Upload Script - command-line

Two questions pertaining to a FTP Batch upload script I'm working on.
1) My log-in script is failing even though I know my credentials are valid. Any suggestions about this code snippet?
open ftp.mydomainname.com
user (ftp.mydomainname.com:(none)):myusername#mydomaninname.com
password:mypassword
2) This is just a general question about FTP scripts. If I don't specify a "lcd" will the script assume when I say "put" that it's supposed to get the file from the directory the script lives in, or must I specify the directory with a "lcd"?

Answered the log-in piece of the question here: stackoverflow.com/questions/936108/
I solved the "lcd" piece of the question like so
put "c:\correct\file\path\here\filename.txt"

Related

Can I upload a file to onedrive via Windows 10 command line?

I need to upload a file to OneDrive, via the command line. This will be done through a batch file which is distributed to end users.
From searching on Stack Overflow, I find questions like this one which say that you need to register an app and create an app password, using Azure. I don't have the necessary permissions to do this in the organization where I work, nor can I do anything that requires an admin account. So I can't any install software - I have to use what comes with Windows 10. I can't use VBA either as that's blocked.
I've managed to download files from OneDrive without anything like that, using the process described here:
Open the URL in either of the browser.
Open Developer options using Ctrl+Shift+I.
Go to Network tab.
Now click on download. Saving file isn’t required. We only need the network activity while browser requests the file from the server.
A new entry will appear which would look like “download.aspx?…”.
Right click on that and Copy → Copy as cURL.
Paste the copied content directly in the terminal and append ‘--output file.extension’ to save the content in file.extension since
terminal isn’t capable of showing binary data.
Example:
curl https://xyz.sharepoint.com/personal/someting/_layouts/15/download.aspx?UniqueId=cefb6082%2D696e%2D4f23%2D8c7a%2
…. some long text ….
cCtHR3NuTy82bWFtN1JBRXNlV2ZmekZOdWp3cFRsNTdJdjE2c2syZmxQamhGWnMwdkFBeXZlNWx2UkxDTkJic2hycGNGazVSTnJGUnY1Y1d0WjF5SDJMWHBqTjRmcUNUUWJxVnZYb1JjRG1WbEtjK0VIVWx2clBDQWNyZldid1R3PT08L1NQPg==;
cucg=1’ --compressed --output file.extension
I tried to do something similar after clicking 'upload' on the browser, but didn't find anything useful when trying to filter the requests.
I found these two questions but there is no keyboard shortcut to upload, AFAICT. Also the end user will be uploading a file to a folder I've shared with them from my OneDrive. Opening Chrome or Edge as a minimised window is fine, but I can't just shove a window in their face which automatically clicks on things - they won't like that.
It's just occurred to me that I might be able to use an office application to Save As the file to the necessary onedrive folder, where the keyboard shortcuts are pretty stable, but have no idea how to achieve that via the command line.
The best and more secure way to accomplish this goal I think is going to be with the Rest API for OneDrive.
(Small Files <4MB)
https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_put_content?view=odsp-graph-online
(Large files)
https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_createuploadsession?view=odsp-graph-online
You still need a Azure AD App Registration (which your admin should be able to configure for you), to provide API access to services in Azure. Coding with the API is going to be far easier and less complicated, not to mention more versatile.

Creating and moving files in sharepoint through powershell

I often have to move a large number of files from one part of sharepoint to another, and the GUI often has issues with data loss or duplication, as well as being extremely repetitive and time intensive.
Ideally I'd really like there to be a way to just navigate sharepoint files as if they were just any other files on a command line in a computer file system. Is such a thing even possible? If not, is there at least a way to cp files from one directory into another?
Things like these make it seem easy, except the file paths don't actually match up in reality to any expected path:
https://www.sharepointdiary.com/2018/03/sharepoint-online-move-files-using-powershell.html
When attempting to use the SPO or PNP module in powershell, the documentation is pretty unclear. Get-PNPfile either always returns file not found if I try to use /Documents/Foldername like one would think. Even if I right click and copy link and get that messy url and make sure to deal with the ampersands, it still doesn't work. For example
Get-PnPFile -Url "https://domain.sharepoint.com/sites/team/Documents/file"
I would expect this to well, return an object that contains something pointing to the file, but it never works.
One possibility is that MFA is a requirement in the environment I'm using and it seems requires a flag -UseWebLogin which appears to work without errors, but it also appears to work when I mistyped the url of the team name when I used the command Connect PnPOnline, so maybe there is an issue there?
First for MFA, it will be better to user Connect-PnPOnline -Url "https://domain.sharepoint.com" -Interactive just like the comment on your original post.
And for the file not found error, it seems you are not using the correct URL. Have a try on the site relative URL.
Here is what I have tested
So, the solution ended up being the use of the "sync" feature which then creates an alias that can be manipulated as if it was a regular file on a machine using powershell. There doesn't seem to be a straightforward way to interact with the sharepoint filesystem via command line which is bonkers.

Call ahk script from url (github gist)

Is there a way to call/load an ahk script from https. Like this one. I'd like to keep this file for public editing on github and it would be called from multiple users without the need to download it first..
How about downloading it:
UrlDownloadToFile, https://gist.github.com/gimoya/5821469/raw/034b2766bbcbe70e2a8e93b72d1ec8723351a8f8/Veg%C3%96K-Abk%C3%BCrzungen, hotstrings.ahk
if(ErrorLevel || !FileExist("hotstrings.ahk") ) {
msgbox, Download failed!
ExitApp
}
Run, hotstrings.ahk
You may want to add some check routines for the downloaded file to make sure, that it's syntactically correct and most of all not harmful. That is, you can't trust anything coming from the internet. A more secure way to apporach this would be to retrieve your hotstrings as XML or JSON and build them dynamically on your own; blindly executing downloaded code is very risky, especially when multiple users are able to edit it arbitrarily.

Filemaker 11 Perform Script in another file

I want to run a script in one file (A) from another file (B). In file B I have a script step: Perform Script [“email test” from file:”A”]
File A is password protected, so when the script runs a login dialog box comes up, but I want this to run automatically in the background without having to enter a password. File B is a timed file? How do I do this?
Add the same username and password in File A as File B.
Then in File A goto File -> File Options and tick Log in using and fill in the credentials.
File A will open without asking for a username/password and when it opens File B to call the script it will pass on the authentication details.
Offhand I can think of three techniques you can use to run the script in File A without needing to enter the password each time.
First, on the Mac there is the option to "Remember my password" when you log into File A. If you check this, FileMaker will look up the password when File B performs the script in File A and should automatically log in. I don't know if such a feature exists in Windows but it might be possible to do the same thing there.
Second, once a user is authenticated with FileMaker, FileMaker will try to use the same authentication credentials for any other database that the first database tries to open. So, as Adam suggests, you can add the same Username and Password used in File A to the Security section of File B. From there you would change the File Options to auto-login with the Username and Password you transferred. You should now automatically log in to both File B and File A.
Third, you could manually log into File A and just leave it open. This technique isn't as robust as the first two as you would need to manually log in again each time the file shuts down or connectivity is lost.
A Few Words About Security
File A probably has a password for a reason. When doing techniques like this it is certainly best to think about security and what people should be allowed to access if they gain access to your computer. At minimum your computer should probably require a password both at login and whenever the screensaver is deactivated just to ensure that people without authorization aren't able to access File A when they shouldn't.
Remember that, with the second technique, anyone who gains access to File B can now access File A with your credentials so you definitely want to be careful with File Sharing and letting others use your computer.

ftp from device

When i send a .txt file via ftp on the simulator it works fine. but when i send it from the device, the .txt file gets send, put not the contents of it.
Can anyone help?
You asked a similar question the other day (and didn't mark an answer.)
How are you trying to upload the file via FTP? Please show us some code.
As I said in my answer to your other question, an easy way to upload a txt file via ftp would be to use some pre-canned FTP library. This one seems to be good, and they have examples on their web page of how to upload files with just a few lines of code:
http://code.google.com/p/s7ftprequest/