I have to transfer a folder structure from Windows to AIX server but I can not install anything more then Putty as this is client machine.
I have tried few alternative.
Tried to ftp Directory structure which is not possible as FTP support only simple file transfer
Tried to execute remote UNIX command execution with putty.exe -ssh -l username -pw password cmd_file.sh. cmd_file.sh is in local windows system contains shell commands but unzip not supported here. I also tried putty.exe -ssh -l username -pw password unix_command and got error "invalid port number"
I tried to execute a shell script file in unix server from windows, it didn't work either.
Make a tar file (using cygwin perhaps on Windows -- you do use cygwin, right?). Then ftp the tarball over. Untar, profit!
Related
whn I try to connect windows server from my unix manually I am able to get the file .
sshpass -p "passwd" sftp username#hosname:path
get filnename unipath
I tired above lines manually and I am able to pull file to my unix path .When tried executing same commands via shell script its throwing below error. Can some one help me .
SSHPASS: Failed to run command: No such file or directory
I am trying to access unix from command prompt using SSH connection with the below command
C:\Program Files\PuTTY>putty.exe -ssh gemini -l usename -pw password
Now i also want to run command in gemini from command prompt.
Will that be possible ?
I have found few solutions as below
C:\Program Files\PuTTY>putty.exe -ssh gemini -l username -pw password -m "C:\path\cmd.txt"
But running that just opens my putty and closes and not sure what is missing.
can someone help me with this please ?
Have you tried to remove doble quotes in file path?
I am trying to run a shell script to execute a binary on a remote linux box. Both the binary and the shell script are on my local window machine. Is there any way through which i can run the binary to the remote machine directly from windows through command line tools like PLINK?
I don't want to put the binary and the script to all the remote linux boxes which
i want them to run on,Instead I want to run the shell script which will intern invoke the binary and do the desirable functions directly through my local machine.
You can run the shell script remotely, just by piping it through ssh:
cat my_script.sh | ssh -T my_server
(Or whatever the windows/plink equivalent is.)
However, you can't run the binary remotely through a pipe, the file will have to exist on the remote server. You can do this by pushing the file from your windows machine to a known location on the remote server, and then editing your script to expect the file to exist in that location:
scp my_binary my_server:/tmp
cat my_script.sh | ssh -T my_server
And then just have your script run that binary:
/tmp/my_binary
Or you can write the script so that it pulls the binary file from a central location where you're hosting it:
wget -O /tmp/my_binary http://my_fileserver/my_binary
/tmp/my_binary
Note, if the shell script doesn't do anything else besides invoke the binary, then you don't need it. You can just fire the commands directly through ssh:
ssh -T my_server "cd /tmp && wget http://my_fileserver/my_binary && ./my_binary"
You will have to copy the binary to the remote Linux box before it can be executed. However, you could have a script on the windows machine that uses sftp to transfer the binary program to a temporary directory under /tmp before running it, so there is no manual setup required.
With PSCP.EXE I am trying to copy multiple files from Unix server to my Windows local.
I am running the below code:
pscp.exe -pw password abc#host:"/batch/a1.btc /batch/a2.TMP /batch/a2.TMP" "C:\Users\Me"
But it takes the source to be one file instead of 3 files, thus cannot copy them.
How can I copy multiple files with PSCP?
It was a while ago you wrote this, but I had the same problem. If the files have same endings, same filetype you could use
pscp -pw password abc#host:/batch/*.TMP C:\Users\Me
Then it will copy all files with the ending .TMP!
Run them in batch mode like this through a script:
pscp.exe -batch -pw password abc#host:/batch/a1.btc C:\Users\Me
pscp.exe -batch -pw password abc#host:/batch/a*.TMP C:\Users\Me
The below command can be used to transfer multiple files using PSCP:
pscp.exe -unsafe -scp -pw password "abc#host:/batch/a1.btc /batch/a2.TMP /batch/a2.TMP" "C:\Users\Me"
I want to transfer a .png file from a directory on my computer to a directory on a remote server.
I have to use SFTP to secure the file and transfer mode. And I already have a UNIX script (.ksh) file to copy the files in the normal mode. How do I implement the transfer in SFTP mode?
Use sftp instead of whatever command you are using in your .ksh script. See sftp man for reference.
You may also want to look at scp secure copy - scp man.
EDIT
sftp is mostly for interactive operations, you need to specify host you want to connect to:
sftp example.com
you will be prompted for username and passsword, and the interactive session will begin..
Although it can be used in scripts, the scp is much more easy to use:
scp /path/to/localfile user#host:/path/to/dest
you will be prompted for password..
Edit 2
Both scp and sftp use ssh as underlying protocol, see this and this
The best way to setup them to run from scripts is to setup passwordless authentication using keys. See this and this. I use this extensively on my servers.. After you setup keys, you can run
scp -i private-key-file /path/to/local/file user#host:/path/to/remote
sftp -oIdentityFile=private-key-file -b batch-file user#host
If you want to authenticate with password, you may try the expect package. The simplest script may look like this:
#!/usr/bin/expect
spawn sftp -b batch-file user#host
expect "*?assword:*"
send "pasword\n"
interact
See this, this and this for more info.
Send commands through sftp on one line:
Make a file and save it as my_batch_file:
cd /root
get blah.txt
bye
Run this to execute your batch file:
eric#dev /home/el $ sftp root#10.30.25.15 < my_batch_file
Connecting to 10.30.25.15...
Password:
sftp> cd /root
sftp> get blah.txt
Fetching /root/blah.txt to blah.txt
sftp> bye
The file is transferred
That moved the blah.txt from remote computer to local computer.
If you don't want to specify a password, do this:
How to run the sftp command with a password from Bash script?
Or if you want to do it the hacky insecure way, use bash and expect:
#!/bin/bash
expect -c "
spawn sftp username#your_host
expect \"Password\"
send \"your_password_here\r\"
interact "
You may need to install expect, change the wording of 'Password' to lowercase 'p' to match what your prompt receives. The problems here is that it exposes your password in plain text in the file as well as in the command history. Which nearly defeats the purpose of having a password in the first place.