I am sending files from a windows system to a Unix SFTP server using JSCAPE ftp client.
However, I am experiencing the following issue:
When uploading a text file from windows to UNiX, each line of text files transferred contains Control-M characters. I did some search and found out that If I use the "ASCII" transfer mode it should solve the issue. But the Ctrl-M is still appearing on the files.
Can anyone throw some light in this issue?
thanks in advance
FTP supports switching between Binary and ASCII transfer mode and converting data on the fly but SFTP does not support that feature and it always transfers files unchanged (at least for the most popular version 3 of the protocol).
The utility dos2unix can be used to convert files from DOS to Unix.
That's the newline character from windows files showing up on UNIX system.
Convert the line endings prior to uploading or find a different FTP server package that can do it for you.
Some text editors have this functionality built in. For instance, Notepad++
Do you have cygwin? You can use the dos2unix utility.
Related
I was downloading a file from one HP-UX server, to an Red Hat Linux server. The file is around 6 or 7 GB.
Using sftp, I tried getting the file, but no matter how many times I try, it always reaches 80% and just exits. No error code, no error description, nothing.
Another team was copying the same file, so they shared their script, and apparently, in the get command, they add ",u":
get XYZ,u XYZ
I tried doing that and to my surprise it worked. However I cannot find that option anywhere else online, and I sort of want to know what is it.
It must be some server-specific hack.
It's not an sftp option. From the local sftp client perspective, you are downloading a file with a name XYZ,u.
I have one .bat script on my windows share that is mounted to my UNIX machine. Bat script is set to make file transfer between 2 windows shares, but I would like to trigger this script from a unix machine if that is possible. I was reading that you can do it with wine or dosbox, but I don't have that installed on my unix. Is it possible to resolve this problem with some additional .sh script that will trigger my .bat script correctly?
Thank you in advance.
Best regards.
You cannot run a .bat script on a Unix machine for several reasons :
Unix has not the same commands (on the command line) as Windows. The POSIX standard defined a set of commands, if you use them you'll be portable on various POSIX systems (but not on Windows); for example to list a directory, you'll use DIR on MSDOS and Windows but ls on Unix and POSIX; to copy a file it is COPY on MSDOS and Windows but cp on Unix and POSIX; etc....
Unix has not the same command interpreter as Windows. The POSIX standard and the Unix tradition provides a Unix shell and POSIX has standardized /bin/sh (a.k.a. POSIX shell). Windows has CMD (inherited from MSDOS) and PowerShell.
The way of interpreting commands is different (on Windows look also into PowerShell, which I don't know). On Unix it is the shell (not the invoked programs) that is expanding your command and globbing. See this answer for more. The notion of current working directory is different.
the operating system concepts are (slightly or significantly) different on Windows and on Unix or POSIX. For example, files, directories, processes, libraries are different (for example, a file can be written by a process and removed by another one on Unix and it can have several names on Linux thru hard links), .... etc.... You could read Operating Systems: Three Easy Pieces for an overview.
the Unix philosophy is not (always) applicable to Windows.
So you need to study Unix (or POSIX) and write your own shell script from scratch. Don't try to "translate" a bat script to a Unix shell script, but redesign it entirely (starting from the problem you want it to solve).
(and Wine or DosBox is not helpful in your case)
Read also about SCP and perhaps FTP. Perhaps using some distributed version control system like git could be relevant for you (e.g. to share scripts, source code, etc...).
If you need to run remotely some Windows .bat script on a distant Windows machine (e.g. from a Unix machine), you should use some remote command running service (that is, find and use some equivalent of SSH service on Windows, and use the corresponding client on Unix). See this.
So if you need to remotely run on a Windows server something (e.g. some program, some script, some command) from a Unix machine you should ask a different question (or at least improve a lot the current one).
Read about the client-server model and about application layer to use the correct terminology. You should name what protocol, server, client, service you want to involve. Nothing is magically "triggered" without using them.
PS. I'm using Unix since 1987, Linux since 1993. I never used Windows.
Preface: About a month or so, we upgraded our work systems from a Windows 7 desktop to a Windows 8.1 Dell laptop. Laptop's file system is NTFS with DDPE file encryption and desktop's file system is NTFS, but no encryption. I tagged in Sublime Text 3 because that's where I have been poking around trying to come up with a solution. I am having issues honing into this specific problem, so I am asking a new question.
Problem: We're getting garbled text issues at the end of file with any extension. Randomly happens to some files on computer restarts. Randomly means it sometimes happens, sometimes doesn't. Happens on projects started on desktop and projects started on laptop. Doesn't matter if the project has been opened during the computer's uptime or not. Seems totally random.
Example: filezilla.xml
</LastServer>
</Settings>
</FileZillZY_ ?
Example: Richmond2015.sublime-workspace
"side_bar_width": 514.0,
"status_bar_visible": true,
"template_settings":
{?c??A
Attempts to fix:
changing between unix and windows line endings
"ensure_newline_at_eof_on_save": true
saving with different file encodings, some were defaulting to Western, changed to UTF-8
I moved a text file from windows to unix. The content in windows file had some special characters like ®,ä which I needed. However after moving it to linux, all my special characters where prepended by Ã. For example if the string was äbcd# it was converted to ÃabcdÃ#. Also some special characters were totally replaced by either - or `. Please let me know how can I protect my special characters from being modified or corrupted.
Update1:
I tried using binary transfer in WinScp. I am still getting the same problem.
Update2:
I tried using dos2unix. It also dint work either.
The problem is caused by the fact that Windows and Unix use different text encoding. Your file on Windows is probably in an ANSI encoding (not ASCII). Unix (Linux?) expects most likely UTF-8.
In notepad save your file in UTF-8 format. Then run the file through dos2unix to fix the line breaks.
Is there some way to access the Windows version of a helpfile on a Linux computer within R?
I write a decent amount of R code on my Linux machine, but I do have to make sure the code will run on a Windows machine for collaborators.
I've been burned a number of times by reading a help file on my Linux machine, writing my code, and then spending hours wondering why it's not working on the Windows machine until I check the helpfile on that machine and realise that it is different to the one on the Linux machine.
It'll usually have a "NOTE: On Windows, xxxx behaves differently...", and I wish I knew that while I was writing the code on my Linux machine!
I do realise that many help files are system-specific (for example ?system), but sometimes I would like to read the Windows version on my Linux computer. Today I found myself wanting to read ?windows but had to boot up my Windows laptop just to read that helpfile, because that function isn't available on Linux and so there's no help file.
cheers.
You can always look at the source which gives you clear conditionals -- this is from man/system.Rd:
#ifdef windows
Only double quotes are allowed on Windows: see the examples. (Note: a
Windows path name cannot contain a double quote, so we do not need to
worry about escaping embedded quotes.)
[...]
#endif
#ifdef unix
Unix-alikes pass the command line to a shell (normally \file{/bin/sh},
and POSIX requires that shell), so \code{command} can be anything the
shell regards as executable, including shell scripts, and it can
contain multiple commands separated by \code{;}.
[...]
#endif