Difference between TEXT mode and ASCII mode in File transfer through FTP? - shell

I am facing a strange issue when transferring file through WinSCP FTP tool.
I downloaded a shell script file from server and made some minor modification. Uploaded this file on same UNIX server through WinSCP Tool.
When I select Transfer settings as Binary, Shell script doesn't work properly and failed. Even generated log file didn't open.
When I select Transfer settings as TEXT it worked properly.
Also, when I set Transfer settings as ASCII in File transfer through FTP command in Terminal, even it didn't work.
On the basis of above issues, I have below concerns:
Difference between TEXT mode transfer and ASCII mode
transfer?
Difference between transferring file through FTP command
via Terminal and using FTP tool like WinSCP, FileZilla, FireFTP?

I think it has to do with translation between Newlines, Carriage Returns and NL/CR combinations. i.e. Transfering a text file from a DOS machine to a UNIX machine, ASCII mode will to the proper translation, and "TEXT" mode (which I believe is really "binary" mode) will just transfer as-is, with no translation.

There's no difference between "text" and "ascii" transfer mode. These are just two names that are used interchangeably for the same mode.
There should be no difference between the text/ascii mode in GUI FTP clients and the Windows command-line FTP client.
Though the can be some implementation detail that might make a difference for a particular server.

Related

Checkout linux project to workspace on Windows

I am using Perforce as a version control system. When I create a new project in Windows and say Get Latest from the Depot a project which was written on Linux and has Linux line endings seems to have Windows Line Endings when it was downloaded to Windows workspace. I do now know who is manipulating the line endings. The version control system itself , namely perforce, or the operating system Windows.
By default, Perforce translates text files into the native format when writing them to a workspace. This is because (for example) most Windows IDEs expect CRLF formatting whereas most Linux IDEs expect LF formatting. Automatic conversion means you don't have to think about it.
If you want to manually set the line endings that a given workspace uses, change the LineEnd option in the client spec; the default local will simply match the standard format for the local platform, but you can specify unix if you want everything to be in Linux format.
https://www.perforce.com/manuals/p4guide/Content/P4Guide/configuration.workspace.line-endings.html
If you want a particular file to always be submitted and synced bit-for-bit without any formatting awareness, use the binary filetype to specify that it should be interpreted as an opaque blob of binary instead of as a text file.

Shell script to download files from SFTP

I am working on building a application that will pull data from SFTP.
Basically I have written a shell script that's run on a cron job daily.
Now I want to know if I can implement some logic in the shell script that will scan the files (for security threats – such as: software viruses, worms, Trojans, adware, etc.) before downloading. Is that possible and how?
You basically want to "remote control" your SFTP session. There are several ways to do this, but I don't see, how you can scan a file for a virus using the (S)FTP protocol, without downloading it. This would require to execute a program on the remote side, and for what I know, FTP does not support this.
Maybe ssh would be the tool of choice. First open a ssh session, do all the checking of the files, then transfer them with FTP. If you are really paranoid, you can calculate the MD5 sum of the file before the checking, and after the download, and verify that they are identical.

how to copy files from solaris to windows

Guys this is my first solaris script. I am really sorry if the question is obvious.
Thanks for your answers. We have a Solaris server in which I want to backup the database and then I want to copy the back up to windows back up server.I am planning to write a Solaris bash script and schedule it to run weekly.At first I was thinking of developing a windows batch file but there are several Linux/Solaris commands that I want to be executed and batch file didn't work well, that's why I decided to do it as a Solaris bash script. On Solaris side I created a script for creating the back up, now my problem is to write a script in which I can copy the back up from Solaris to windows back up server over the network.
Thanks
It is not clear from your question if you need to write a script that can do the transfer of files in an automated way ... or if this is an ad-hoc requirement. Anyway I'll go with the latter just like the other answers you've got so far.
For anything related to working with Linux/Unix hosts from a Windows box you'll enjoy MobaXterm. It's an all-in-one handy tool that wraps all the other tools that you would otherwise have to install (terminal emulator, scp, ftp, X server, etc). I can only recommend it. There's a free version. (no, I'm not affiliated with MobaXterm in any way).
Here's a picture where I've logged into a Solaris box.
The right-hand side is essentially an embedded Putty. The left hand-side allows you to upload/download files to/from your remote host, in this case a Solaris host. You would press the buttons I've circled.
MobaXterm has tons of other features packed in a footprint of only 15 Mb.
Easiest option:
Start Command Prompt on Windows box, type;
ftp <solaris-ip>
username password
bi
get <file>
quit
Second easiest option:
Install FileZilla FTP server on Windows
Sit at Solaris box & start xterm
ftp <windows-ip>
username password
bi
put <filename>
quit

How to transfer a file from unix server to windows pc

Right now I am using winscp to manually copy files from unix server to my windows desktop.
I Would like to automate the same by running some script in unix.
Can someone please help?
-Sajith
The simple answer is: run an FTP server on Windows and write a simple FTP client script on Unix.
For Windows, you can use
IIS (built in to all versions of Windows, but switched off by default)
Filezilla -- free https://filezilla-project.org/download.php?type=server
one of the many proprietary FTP server programs. See http://en.wikipedia.org/wiki/List_of_FTP_server_software
At the Unix end, write a script to control the built in FTP client.
Another answer is: use IIS on Windows as a file uploader/downloader by writing a really simple Web site. Use wget or curl at the Unix end.
Another answer is: implement SAMBA on Unix, so that it joins your local Windows network. Copy files using standard shell commands.
Another answer is: use Dropbox and transfer files via the cloud.
I could probably think of more, but that's enough.

Have a Linux shell script stuff a string into a Windows user's copy/paste buffer

We have a script right now which our Windows users run on a Linux host by way of putty. From time to time the script produces a string that the user must copy and paste into a Windows application.
Without running a full-blown X display server on the Windows box, I'd like to modify the script so that the string is populated in the Windows user's copy/paste buffer automatically so that it's more convenient for the user and so that we reduce the error rate (the workflow is clumsy enough, we'd like to make it a little less so).
Here's what I don't consider solutions:
Running a full blown X display manager on the Windows side just for this (if there exists a nearly invisible utility that enables just this one feature that's a different story)
Make the user stop running Windows
Rewrite any other applications
I have full control over the Windows user's environment (can set up whatever putty settings I need to) as well as the Linux host and every node in the network between the two.
If I had to do this I'd probably grab the sources to putty and modify it to suit.
Failing that I don't think you'll be able to easily do this; except by writing a small script on the Linux box that will open a socket to the a small windows deamon and send the text across to be put into the Windows clipboard.
If the remote script doesn't need full terminal support but only does simple stdin/stdout operation, then you might be able to use plink to provide a simple text-only interface which can probably be scripted more easily than a full PuTTY window.
http://ericmason.net/2010/04/putty-ssh-windows-clipboard-integration/
This guy's script patches putty to just what was suggested above. I think it would be more elegant to have just a printer driver you can install in windows to get text to the clipboard, rather than patching putty, but this works!

Resources