Batch script to run in SFTP


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Batch script to run in SFTP
# 1  
Old 05-24-2013
Sun Batch script to run in SFTP

Hello Guys,

I am writting a script which is SFTPing from Solaris to Windows.

I need to run a Batch script in SFTP session (ongoing) which will map a network drive and then transfer my files.

I can run the Batch script via SSH but not via SFTP and this mapping is limited to that SSH session.

Please suggest.
# 2  
Old 05-24-2013
sftp is not shell. If you want shell scripts, use a shell.
# 3  
Old 05-24-2013
Look at the manual page for the sftp client, specifically the -b flag.

Be aware that you must have certificates in place for password-less authentication.


Have a go and let us know where you get stuck and what you have tried so far.




Robin
Liverpool/Blackburn
UK
# 4  
Old 05-27-2013
hi rbatte1,

I need to run windows batch file at remote in SFTP session. In SSH I can do the same by typing ./script_name
But SFTP doesnt support it.

Please help

---------- Post updated at 05:50 AM ---------- Previous update was at 05:42 AM ----------

hi Corona866,
I really dont have problem using ssh or any other shell. But my requirement is I need to map a drive at remote end and then transfer a file.
Mapped drive only has session life and for that I need to have script run in SFTP.

Or else is there any way we can run below command in SFTP,

net use r: \\host\dir password /user:doman\user
# 5  
Old 05-27-2013
Quote:
Originally Posted by Deei
hi Corona866,
I really dont have problem using ssh or any other shell. But my requirement is I need to map a drive at remote end and then transfer a file.
Mapped drive only has session life and for that I need to have script run in SFTP.

Or else is there any way we can run below command in SFTP,

net use r: \\host\dir password /user:doman\user
No. I repeat -- sftp is not shell. If you want to run shell commands, use a shell.

You may be able to do something like this:

Code:
ssh username@host 'net use r: \\host\dir password /user:doman\user
type > outputfile' < inputfile

Which should hopefully map the drive, then dump standard input intout 'outputfile' on the remote end.
This User Gave Thanks to Corona688 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SFTP or scp with password in a batch script without using SSH keys and expect script

Dear All, I have a requirement where I have to SFTP or SCP a file in a batch script. Unfortunately, the destination server setup is such that it doesn't allow for shell command line login. So, I am not able to set up SSH keys. My source server is having issues with Expect. So, unable to use... (5 Replies)
Discussion started by: ss112233
5 Replies

2. Shell Programming and Scripting

How to run sftp in shell script without prompting for password?

Hi, Can anyone tell me how to pass password in a shell script for sftp so that i can run it in background without user entering the password? I used a expect script but it timesout after some time and the process remains incomplete at the end. Can anyone suggest any other idea? Will the... (3 Replies)
Discussion started by: Little
3 Replies

3. UNIX for Advanced & Expert Users

Need a exit from sftp if its ask for password and continue to run remaining part of script.

Hi I am checking status of sftp in Health check script, sftp command is used to connect the server with secure RSA key, which is successfully get connected most of the time but in some case if RSA key ask for password then I need to exit sftp command after few second and continue to run... (1 Reply)
Discussion started by: ketanraut
1 Replies

4. Shell Programming and Scripting

Need to run the batch script from shell scripting

Hi All, I am working on shell scripting.My script is completed but I have one task that is to trigger the batch script(with or without parameter) from my shell scripting(reside on linux system) and output which is geneareted by the batch should e.g. if batch script creates any files then I want... (5 Replies)
Discussion started by: anuragpgtgerman
5 Replies

5. AIX

How to write a script to run without password on a batch of servers?

I need run a command such as ps -ef |grep xxx on a batch of servers, how to write a script to run it without password? don't need go in each server to check? Thanks (7 Replies)
Discussion started by: rainbow_bean
7 Replies

6. Shell Programming and Scripting

To run a shell script in remote server from windows batch file

Hi all, i need to run a shell script on remote server. I have created file .bat file in windows server with following code, c:\Users\Desktop\putty.exe -ssh -pw password user@server ./script.sh i need to run the script.sh in my remote server Above command is not working, any... (4 Replies)
Discussion started by: rammm
4 Replies

7. Shell Programming and Scripting

How to run a script using batch file?

the manual process which we follow is login to remote unix box thro putty using the unix account and password and then sudo to root user. server name:abc@server.com login as:pqrst password:****** $ sudo su - root then run the script stored on remote server under root account. ... (9 Replies)
Discussion started by: gpk_newbie
9 Replies

8. Shell Programming and Scripting

sftp batch script with password

I am working on a sftp batch script on a Solaris machine and I need to connect using password. This is not an issue when i do it manually but when I want to make this into a script, i find there are no options for password. Can anyone suggest how I can do it with password? I know using keys is... (3 Replies)
Discussion started by: Leion
3 Replies

9. UNIX for Dummies Questions & Answers

SFTP batch script

Hi, I am running an sftp batch script. sftp -b user@host <<EOF >> /tmp/file.out binary put file.txt bye EOF However, I am getting errors. No such file or directory (user@host). I checked the forums which says I need to access the current process eg for linux I would... (3 Replies)
Discussion started by: Bab00shka
3 Replies

10. Shell Programming and Scripting

How to write a Script to run series of batch jobs on unix platform

Im new to unix shell scripting, I have to run batch jobs on unix. for example i have 5 jobs. first 2 can kickoff parallely. after completely finishing the 2 previous jobs the 3 job should kick off..once 3rd is over 4 th and 5th can kick off parallely. Each jobs run for 1 or 2 hours each. How to... (2 Replies)
Discussion started by: venki311
2 Replies
Login or Register to Ask a Question