how to copy files from solaris to windows - bash

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

Related

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.

monitor a directory and pull new files as they appear - bash script

I need to pull log files from a Windows server. The log files appear every minute and I am trying to ftp to the server pull the file back to the linux box and process it. I have been looking around and found about inotify, I am not sure how to use it in a bash script after ftp to the Windows server. I am open to other implementation it does not have to be ftp/inotify but I am not sure how this could be done.
any ideas??
Two products come to mind depending on how you plan to approach the solution.
I personally use Splunk on a variety of platforms (Windows & Linux servers/local Linux & OSX dev environments). It is a real-time log aggregator that features an API and the ability to query. Even if this doesn't solve your problem, the free version has some very robust features that you should consider: http://www.splunk.com
The second approach would be synchronization of your web directories using something like RSync. I've used RSync on Linux boxes and always appreciated what it can do. I even see it now has a Windows port: https://www.itefix.no/i2/cwrsync

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!

How to spawn Linux process from Windows application?

My interactive 32-bit Windows app (now moving from Delphi [Ent] 2007 to 2009) uses command-line interactions to spawn child processes that do computationally-intensive tasks, which in turn write text files that the GUI parent app parses and analyzes - resulting in an interactive graphical display of the results.
I have access to a multiprocessor (multi-user) Linux cluster (via ssh), and would like to off-load the heavy lifting to that cluster. My question is how to spawn the processes in Linux from my Windows app. I can envision using secure FTP to put and get files, but not sure how to spawn the child processes in Linux.
Some leads for further reading would be fine - but code/pseudocode would be ideal. I can imagine that this may be more about Windows-Linux interaction than Delphi.
if you have access to ssh, one option is to issue commands through that.
For example:
ssh user#host ls -l ~
will in the ssh terminal show the files in the user's home directory. I'm not sure if this is what you really want. But it would likely work.
If you do this, you almost certainly want to setup SSH password less logins
However, A more ideal solution would likely be to setup a daemon on the linux boxes whose sole job is to run specific long running tasks in the background and let you fetch the results later.
You're going to have to install something on the Linux machine to run the process. You might find some kind of clustering or batch job submission API you can install and access from Windows. You might have to code a custom server. You might be able to run everything over ssh if you can drive an ssh process from Windows and if you have sshd installed on the Linux side. But my preference would be to write a webservice or simple CGI script on the Linux side designed to take your arguments and data and return the result over plain old http (or https as the case might be).
One way or another, this is going to encompass more than just coding on the Windows side.
I would download the full "putty" package.
As well as the excellent secure shell terminal, it includes PSCP to transfer files securely and PLINK to remote execute commands over SSH.
Hint: you will need to set up the full public/private key configuration for PLINK to work without an annoying password prompt. There is a useful guide http://unixwiz.net/techtips/putty-openssh.html>here.

Invoking windows batch file from Linux

I have an application running only on Windows and a batch file that launches it.
I want to invoke this batch file from Linux, meaning something like Linux batch will launch the windows batch with parameters and this in its turn run my application.
Can I do that? How?
You could install an ssh server in the windows box (Cygwin has one), then from linux do something like:
ssh user#windows-box c:/path/to/batch.cmd
and that should launch your application in the windows box.
The most direct way is probably to install an ssh server on the windows box. Cygwin includes an ssh server.
Depending on how precise your timing needs are, you might be able to have an "at" job on the windows box that runs periodically (every 5 minutes?) and runs if it sees that a particular file exists, deleting the file. Then you could use Samba/smbclient to create the file. You would need to turn on filesharing on the windows box for this to work.
If the windows box has a web server, you could write a CGI, and trigger it using wget or cURL.
Our build process currently goes the other way: a windows sever kicks off things on the Linux server using plink (part of PuTTY). You might be able to set something similar up.
This may cause a security issue. Our information security person did not allow me to invoke any programs directly.
The safer way is to set up server on Windows computer. This can be a web-server for example. And then invoke your process inside PHP/Perl/Python script.
Also look at winexe that allows you to execute windows commands/batch scripts without running ssh server.

Resources