WinSCP removes line breaks on upload - file-upload

I use WinSCP as ftp client and i have the transfer set to binary. I also use Notepad++ as editor.
Hovewer every file i upload, is stripped of all line breaks.
<?php
// this is a comment
echo 'this is an echo';
?>
Gets turned into
<?php // this is a comment echo 'this is an echo'; ?>
Outputting nothing beacause it is interpreted as comment.
Do I have to set something else to upload files without any problem?

With FTP protocol, WinSCP never modifies line endings itself.
So it's either your editor or the FTP server.
Find a local temporary copy of the file you have opened in Notepad++. Open it in a binary viewer/editor and check, if the line-end characters are present.
Check if Ascii/Text or Binary mode is used for the upload. WinSCP defaults to Binary mode. But you may have configured it to use Ascii/Text mode. While this should not remove the line endings, there maybe some issue with FTP server. Forcing (default) Binary mode may help.
Download the edited file using Binary mode and open it in binary editor/viewer and check if the line-end characters are present. Or do binary compare against the local temporary copy. They should be binary identical, if the Binary mode was used for upload.

Related

unable to open text file

I'm trying to get a program to open a file and read from it. However, I can't seem to get it to open the file. I've read several threads about this and I've seen the suggestion to make sure the file is in the same directory as my executable. I don't know how to check if that's true. The text file is saved in the same file as my program files, if that helps. Can anyone give me some input? Relevant code below. Thanks!
std::ifstream myfile;
myfile.open("../ResInput.txt", ios::in);
if(myfile.is_open()){
getline(myfile, stemp1);...
Your open() call is trying to go up one directory to read the file as it's written right now. If you want the file opened in the same directory as your executable, remove the ../ in your open() call.
This is also assuming your OS accepts a forward slash as a directory separator. It would also be useful to know the error you are getting.

VB.NET - Shell batch file vs. Manually opening batch file = different results, for PSFTP.exe

I am using a Script Task in SSIS. So I am writing in vb.net. I have a substantial amount of code that ends up writing two files: one is a .bat file with this EXACT contents in it, minus I've changed hostname, username, and password of course:
C:\Users\ipisors\AppData\Local\Temp\091014121929_Phoenix\psftp.exe -pw PASSWORD -b C:\Users\ipisors\AppData\Local\Temp\091014121929_Phoenix\091014121929.txt USERNAME#HOST
(I'm sure it has this, because I manually check it after the Script Task runs).
The content of the .txt file referenced in the command is this EXACTLY:
cd uploads
cd OUT
mget PhoenixEnrollment_20140910*.txt
bye
MY QUESTION -
After the script task runs successfully, there is no downloaded file inside the directory of PSFTP.EXE (C:\Users\ipisors\AppData\Local\Temp\091014121929_Phoenix). Nothing.
However, if I manually double click on that same batch file that the script task was supposed to SHELL(), it immediately works perfectly. Within a few seconds, there is a downloaded file inside C:\Users\ipisors\AppData\Local\Temp\091014121929_Phoenix
What could possibly be the difference in reaction from the FTP server, between my script task code:
Shell(strBatPhoenix, AppWinStyle.NormalFocus, True)
(which by the way - yes I can actually see it working!)
and double clicking the same da*n file
I've also debugged the script task, it's definition Shelling out the EXACT SAME bat file.
Help please!
I will say the password to the SFTP site has a caret (^) in it, which I am escaping by using a double caret.
Figured it out after additionally testing one other way:
I used the command prompt itself to run my batch file. It ALSO did not download to the expected directory. I began to suspect that, even though the Shell was automating a batch file in the 'desired' folder......that batch file was then reading the 'local' directory as whatever calling application had initially Shelled it out.
In this case: c:\users\myusername. And therein was my file.
Lesson to be learned: Shelling a batch file, even if that batch file shells another file, may end up with one application or another reading your instant directory as the instant directory of the application that did the first shell, not the last shell.

invalid byte 2 of 2-byte UTF-8 sequence in resource files after importing the worklight template

I'm trying to create a Worklight project in Worklight Studio 6.1 from a template. It's a straight forward process as described here: http://pic.dhe.ibm.com/infocenter/wrklight/v6r1m0/index.jsp?topic=%2Fcom.ibm.worklight.dev.doc%2Fstudio_ext_assets%2Fc_wl_project_templates.html
However I'm getting "invalid byte 2 of 2-byte UTF-8 sequence" exceptions on some of the settings.xml files inside the android environment's native resources when trying to compile newly created project.
The files are in utf-8 inside the template and I have utf-8 set up for my workspace file encoding ( Preferences->General->Workspace ).
But after extracting stuff from the template ( which is really a zip bundle ) looks like it changes encoding somehow.
Problem goes away when you try to re-save .xml file (for example - open it, add a char somewhere, delete it and save). But this is not an option since we are going to deliver the template to a customer and this will affect the 'user experience'.
Also, the same exact template works fine on linux platform. I saw this issue on windows.
Has anybody experienced this before and could share any info on how to fix it?
Thank you.
Make sure that under Preferences->General->Workspace in Eclipse, the default text file encoding is set to UTF-8 and not US-ASCII (usually by default it is set to ASCII). This should take care of the encoding problems.

Default file transfer mode in SCP

I want to know what is the default mode used (ASCII or binary like FTP) while transferring files using SCP.
Is there any file mode concept in SCP ? How does it work ?
The file transfer modes in FTP are used to solve the problem of different operating systems having different line endings. The idea is that if a text file is transferred from a Unix machine to a Windows machine, the line endings must fixed, meaning that LF must be replaced by CR LF everywhere in the file. The reverse operation must be done when transferring the file in the other direction.
However, if you're transferring binary files, you want to leave the file as-is, because any LFs in the binary file are not actually line endings. Therefore, FTP introduced ASCII mode and Binary mode.
This is still a problematic solution, especially because the default mode is ASCII mode, so if you forgot to switch modes you might mangle your binary files and they won't work. The different modes are considered to cause more trouble than the problem they solve.
And so, SCP simply does not provide this feature, and always leaves the files as is. Fixing line endings is left to the user using tools like dos2unix and unix2dos.
In essence, all files are transferred in "binary" mode, meaning that line endings are never changed.
According to my knowledge there is no mode for scp.
See this man page for more details
I want to know what is the default mode used (ASCII or binary like FTP) while transferring files using SCP.
Unfortunately, in my experience, it depends a bit on the implementation of scp on the OS you are running on. For example, although linux scp doesn't seem to do make any changes to the files -- i.e. EOL characters are not converted between Windows and linux, this is not true under z/OS (sic). On the IBM mainframe, all files being scp-ed seem to be converted from ASCII to EBCDIC character encoding by the scp application itself.
However, it looks like sftp by default does not do the character converting so files come over in their native ASCII.

Trying to create .htaccess file using ftp doesn't work

I want to create a .htaccess file in a specific directory. I'm using Notepad++ and their plug-in for FTP (NppFTP). I'm able to create any other files and see them in the folder but when I try to create a .htaccess I don't see that file in the directory. I get no errors, it is like nothing happened.
I tried to create this file using an FTP program and it showed the file and right away it disappeared. My guess it is because this is a special file used by the system and prefixed by a (.)
What is a way to edit that file?
This is probably because your ".htaccess" file is a hidden file and your system is set up to no display hidden files.
Have a look in your Notepad++ settings if there's an option to make hidden files visible/unhide.
In addition to that check the windows folder options for that option!
switch on showing hidden files in your ftp client