BatchMode issue


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers BatchMode issue
# 1  
Old 03-23-2008
BatchMode issue

Hello All,
I have an issue with sftp in BatchMode option. I am using the below command to sftp a file in ssh2 from a script.

sftp -o BatchMode=yes userid@servername <<EOF
cd /ftp/cds
put quotes.csv
quit
EOF

But the connection doesnt returns back from sftp and it just hangs in the connected mode forever. I had to terminate the program to exit the connection. Can someone please advise how can i resolve the issue ?

Thanks,
Sateesh
# 2  
Old 03-24-2008
Does the sftp gets successfully connected or not ? Wrap the whole thing in a expect script, get the return status with simple "if" - there are many examples in the forum.
# 3  
Old 03-24-2008
The connection actually establishes bet it doesnt come back and i had to kill the job explecitly.
Can u please refer me some examples to avoid this issue. Is there is any other option other than -B option
# 4  
Old 03-25-2008
Why not :
Quote:
-b batch-file-path
specify -b flag, add the same commands in a file, enter the path to it, and see if it happens.
Otherwise in expect :
Code:
#!/usr/bin/expect

set timeout 10

if { $argc != 3 } {
    puts "Usage $argv0 host user pass "
    exit 1
}

set host [lindex $argv 0]
set user [lindex $argv 1]
set pass [lindex $argv 2]

spawn sftp -o Port=22 $user@$host
expect *assword:

send "$pass\r"
expect sftp>

send "$your-command-here\r"
expect sftp>

send "exit\r"
expect eof

With this generic script, you can specify the timeout to be 10 seconds.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

What could be the issue ?

Hi, when i am trying below script assume that below values are taken in code #!/bin/ksh if then echo usage: aNlist.sh QMGR NAME MQREQ fi NL=`echo 'dis qmgr'|runmqsc $1|grep REPOSNL|sed 's/.*REPOSNL\(.*\).*/\1/' |cut -d'(' -f2|cut -d')' -f1` echo 'define nl('$NL_$2')... (25 Replies)
Discussion started by: darling
25 Replies

2. Shell Programming and Scripting

Variable value substitution issue with awk command issue

Hi All, I am using the below script which has awk command, but it is not returing the expected result. can some pls help me to correct the command. The below script sample.ksh should give the result if the value of last 4 digits in the variable NM matches with the variable value DAT. The... (7 Replies)
Discussion started by: G.K.K
7 Replies

3. Shell Programming and Scripting

Need assistance with a file issue and a terminal issue

Hello everyone, I'm in need of some assistance. I'm currently enrolled in an introductory UNIX shell programming course and, well halfway through the semester, we are receiving our first actual assignment. I've somewhat realized now that I've fallen behind, and I'm working to get caught up, but for... (1 Reply)
Discussion started by: MrMagoo22
1 Replies

4. UNIX for Dummies Questions & Answers

ISSUE and ISSUE.NET files

In LINUX(CentOS, RedHat) is there a way to have the banner statement appear before the logon instead of after the logon? In UNIX and Windows the banner appears before a person actually logs on, what I'm seeing in LINUX is that it appears after the login(ftp, telnet, SSH). Thanks (0 Replies)
Discussion started by: ejjones
0 Replies

5. Shell Programming and Scripting

hi all please help me in this issue.

Hi all, I am very new to shell scripting.I have the requirement like one program is there, if it is running leave like that only and if it is stopped it has to be restart and once again keep watching and it is stopped we a have to restart once agian.I want a shell script for this.Please help me... (10 Replies)
Discussion started by: bhas85
10 Replies

6. Shell Programming and Scripting

please help me in this issue

I have the log file as this date 18:00:00 date 18:01:02 date 18:02:00 date 19:06:00 date 18:03:00 date 18:05:00 I want to get date between 18:00:00 to 18:05:00. I given the command as grep file name but it is not working. Please give me reply. Thanks & Regards, Vijay, (3 Replies)
Discussion started by: bhas85
3 Replies

7. Solaris

SunOS 5.8 sftp-BatchMode Problem

Hi Gurus I have to connect from a SunOS 5.10 to a 5.8 using sftp in BatchMode. For this, I have generated a Public-Key (ssh-keygen -b 1024 -P "" -t dsa) on the 5.10 and saved it in ~remote-user/.ssh/authorized-keys on the 5.8. Then, running either one of ssh or sftp, it asks for the... (0 Replies)
Discussion started by: unilover
0 Replies

8. Shell Programming and Scripting

sftp BatchMode issue

Hello All, I have a issue with the below script that i am using to sftp a file. sftp -o BatchMode=yes $sftpLogin <<EOF cd /ftp/cds get cdstesting.csv quit EOF When i use this, the connetion establishes and the connections doesnt returns from and hangs in the connecting mode. I think... (0 Replies)
Discussion started by: kotasateesh
0 Replies

9. Shell Programming and Scripting

Unix Arithmatic operation issue , datatype issue

Hi, I have a shell scripting. This will take 7 digit number in each line and add 7 digit number with next subsequent lines ( normal addition ). Eg: 0000001 0000220 0001235 0000022 0000023 ........... ......... ........ Like this i am having around 1500000 records. After adding... (23 Replies)
Discussion started by: thambi
23 Replies

10. UNIX for Dummies Questions & Answers

ps issue

HI All, Suddenly don't know what happened to redhat linux 7.2 any program start then itsn't listing while using ps -ef ex: ./xyz this xyz program pid not showing in ps-ef Pls let me know what is the reason for the same. Thanks a lot in advance Bache (7 Replies)
Discussion started by: bache_gowda
7 Replies
Login or Register to Ask a Question