Open and System command in SFTP


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Open and System command in SFTP
# 1  
Old 04-11-2011
Question Open and System command in SFTP

Hi Unix team,
Is there any alternative option and command which one can use in ftp for sftp usage.

open, system command --> alternative for sftp usage
-n option --> alternative for sftp usage
sftp supports only binary transmission.
how one can achieve ascii mode file transmission in sftp.

example:
can i use code like this:
Code:
sftp -b /dev/stdin -v <<EOF
open remoteserver
system
put localfile remotefile
quit
EOF

# 2  
Old 04-11-2011
then try ftp client..
Code:
ftp localhost
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ascii
200 Switching to ASCII mode.
ftp>

As for as i know sftp does not yet support other than binary mode. maybe thinking is not needed this.
because in unix/linux to unix/linux (same) systems file transfer issue is not problem.

you can try like this
Code:
sftp localhost -b </dev/stdin <<EOF
put localfile remotefile
quit
EOF

regards
ygemici
# 3  
Old 04-11-2011
Java

Hi ygemici,

Thanks for your reply.

i have to use sftp only. so for ascii mode transfer alone i cant use ftp.

The code which you have mentioned ,
Code:
sftp localhost -b </dev/stdin <<EOF

is it in correct syntax.I dont think so. why do we need to mention localhost.
Moreover my Question is 'can one use Open command in sftp?' because in man page of sftp ,open command is not present.

Please help anyone.
# 4  
Old 04-11-2011
Quote:
Originally Posted by mayleeshwaran
Hi ygemici,

Thanks for your reply.

i have to use sftp only. so for ascii mode transfer alone i cant use ftp.

The code which you have mentioned ,
Code:
sftp localhost -b </dev/stdin <<EOF

is it in correct syntax.I dont think so. why do we need to mention localhost.
Moreover my Question is 'can one use Open command in sftp?' because in man page of sftp ,open command is not present.

Please help anyone.
Hi

I just test for localhost..however you can use any IP that you want to connect host.
And syntax is seem correct for localhost and did you try?
open command is not use in sftp..because of this i use IP (in my example as localhost)
in binary mode you can transfer binary and text files without any corruption (or interpretation problem) for unix-to-unix systems.
and sftp only uses SSH 2 protocol so remote host must support this.
what is your goal?

regards
ygemici
# 5  
Old 04-11-2011
Look at lftp - a client that understands ftp, sftp, fish and http protocols and can be scriptable. You can specify ASCII transfers and I think it's possible under the sftp protocol.

If you use Linux it may be in your repositories. If not you will need to compile & install it.

Andrew
# 6  
Old 04-14-2011
Hi ygemici,

Thanks for your reply. Sorry for the late reply.
my goal is , i need to transfer file from unix to webmethods installed Linux/unix system. And what about system command.? in sftp.
Using Openssh i need to do these file transfer.
Do i need to call ssh program before calling sftp or internally it ll happen (when using shell script) like this:
Code:
#The below has declared in config file and i am using shell script for file transfer.
#path=usr/bin/ssh
#sftppath=usr/bin/sftp
#remoteaddress=user@remotehost
$path remoteIP
$sftppath -b /dev/fed/0 -v  $remoteaddress<<endsftp
filetransfer code...
endsftp

if any error on this state your reply with code example.

Thanks in advance.

---------- Post updated at 12:47 PM ---------- Previous update was at 12:32 PM ----------

Hi andrew,

thanks for your reply. I have instructed to use sftp only and i dont know much about lftp.
# 7  
Old 04-16-2011
Hi
why do you want to make sftp via use ssh command?
sftp does it already Smilie

did you try your code ? your batch file is in /dev/fed/0 ?
Code:
-b /dev/fed/0

you can try this simple script Smilie
Code:
remoteadr=user@remotehost
sftp $remoteadr << EOF
filetransfer code...
quit
EOF

regards
ygemici
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Red Hat

Checking open ports in a system

Hi, There are two servers which needs to be connected via the port number 1521 from a remote server. This is the port config in the first server : L28tstream1 : # netstat -tulpn | grep 1521 tcp 0 0 10.67.26.183:1521 0.0.0.0:* LISTEN ... (2 Replies)
Discussion started by: anaigini45
2 Replies

2. Programming

open() system call in c++????

Hi friends, I am trying to use the open system call in c++ language. Please have a look at my code. vi Open.cpp 1 #include <stdio.h> 2 #include <iostream> 3 4 #define BUFSIZE 1 5 6 using namespace std; 7 8 int main() 9 { 10 ... (5 Replies)
Discussion started by: gabam
5 Replies

3. Shell Programming and Scripting

SFTP-how to log individual sftp command error while executing shell script

Hi, I have situation where i need to automate transferring 10000+ files using sftp. while read line do if ; then echo "-mput /home/student/Desktop/folder/$line/* /cygdrive/e/folder/$line/">>sftpCommand.txt fi done< files.txt sftp -b sftpCommand.txt stu@192.168.2.1 The above... (1 Reply)
Discussion started by: noobrobot
1 Replies

4. UNIX for Advanced & Expert Users

Link from mount point to sftp account of file system

Hi, Is it possible to do hard link between the mount point of file some structure to the sftp account of some other server ? If possible then what could be the behavior of link properties? Is it could be the same as we found in our environment (unix/linux). Even if we do such link , then it... (1 Reply)
Discussion started by: posix
1 Replies

5. Shell Programming and Scripting

Shell script to Open file in SFTP and get first 6 character

Hi, I am creating a script that will: 1. Connect to SFTP server 2. Get the file content's first 6 character (ddmmyy) and compare it to today's date (also in ddmmyy format). This is the header of the file. However, the header contains a few more information. So i need to only get the first 6... (0 Replies)
Discussion started by: cherriesh
0 Replies

6. SCO

SCO Open Server 6 - System Halt

Dear All, Newbie here, hope my post goes to the correct room. System: SCO Open Server 6.0 Everything running well, after this Sunday morning noone can login via telnet or via putty, the system suddenly reject without any message (and also ftp). The local IT Support there (without enough... (2 Replies)
Discussion started by: virgani
2 Replies

7. UNIX for Advanced & Expert Users

System Call Wrapper of 'open'

When the programmer use 'open' function, the process is like below. "open -> system call wrapper of open in Glibc -> syscall_open in kernel" I found the wrapper of open, but there is no implementation like 'int $80'. int __open (file, oflag) const char *file; int oflag; { ... (3 Replies)
Discussion started by: yuno96
3 Replies

8. Shell Programming and Scripting

SFTP to MVS system

Hi All, I have written a script that transfers(FTP) files from Unix system to MVS system. Below is the code for it. ftp -inv $HOST<<ftp_test quote site LRECL=200 quote site BLKSIZE=28000 mput SOURCE DEST ftp_test Here I need the help, if the above code can get... (3 Replies)
Discussion started by: rinku11
3 Replies

9. AIX

Open Ports on System

Hi Every body, What is the command on AIX 5.2 that can be used to get all open ports? (2 Replies)
Discussion started by: aldowsary
2 Replies
Login or Register to Ask a Question