How to create a file in remote server from local server?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to create a file in remote server from local server?
# 1  
Old 05-17-2013
How to create a file in remote server from local server?

hi,

can anyone tell me how can i store the names of a file that are in remote server to a file and then get the file that contains the name in local server?

there is a remote server where 5 files are present , say

Code:
a.txt
b.txt
c.txt
d.txt
e.txt

i want to write a script in my local server, which will connect to remote server and write all the filenames that are present in remote server (a.txt, b.txt, c.txt, d.txt, e.txt) in a temporary file say filenames.txt.

so filenames.txt will have the contents

Code:
cat filenames.txt
a.txt
b.txt
c.txt
d.txt
e.txt

after this i want to transfer this file (filenames.txt) to local server using any protocol?

please suggest ideas or scripts if it is possible.

thanks
# 2  
Old 05-17-2013
What all protocols are available for you to use?
# 3  
Old 05-17-2013
Quote:
Originally Posted by Little
please suggest ideas or scripts if it is possible.
If you can use 'ssh' this is one way to create a file on local host and populate with file names form remote host:
Code:
ssh user@remote_host 'ls /path/to/files/*' > /tmp/file_list.txt

# 4  
Old 05-17-2013
i can use ftp, scp..

---------- Post updated at 10:05 AM ---------- Previous update was at 10:05 AM ----------

if any other way it can be done.. please tell

---------- Post updated at 10:09 AM ---------- Previous update was at 10:05 AM ----------

Quote:
Originally Posted by spacebar
If you can use 'ssh' this is one way to create a file on local host and populate with file names form remote host:
Code:
ssh user@remote_host 'ls /path/to/files/*' > /tmp/file_list.txt

but how will i provide the password in this case automatically, because the script will be running without any user interaction.

by using ftp, i can pass the password like

Code:
ftp -n remote_machine <<_ftp
  quote USER username
  quote PASS password
  ls
  bye
_ftp

is there any other way to provide the password ?
# 5  
Old 05-17-2013
Even i would sugest ssh. It would be better option.

You have to setup password less ssh. You will find lot of docs over internet regarding its settings Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Best way to transfer files to remote FTPS server instead of local FTPS server

Hi, I am working on an application which runs on an Informatica Red-Hat 5.10 Linux Server. The application involves several Informatica ETL workflows which generate 100s of Text files with lot of data. Many of the files will each be up to 5 GB in size. Currently the Informatica server itself... (7 Replies)
Discussion started by: waavman
7 Replies

2. Shell Programming and Scripting

How to Append the output of a script running in remote server to a file in local server?

Hi guys, So i am in server1 and i have to login to server 2, 3,4 and run some script there(logging script) and output its result. What i am doing is running the script in server2 and outputting it to a file in server 2 and then Scp'ing the file to server1. Similarly i am doing this for other... (5 Replies)
Discussion started by: srkmish
5 Replies

3. Solaris

Script to get files from remote server to local server through sftp without prompting for password

Hi, I am trying to automate the process of fetching files from remote server to local server through sftp. I have the username and password for the remote solaris server. But I need to give password manually everytime i run the script. Can anyone help me in automating the script such that it... (3 Replies)
Discussion started by: ssk250
3 Replies

4. Shell Programming and Scripting

preserving the timestamp of a file when copied from remote server to local server using ftp

Hi, I need to copy few files from remote server to local server. I write a shell script to connect to the remote server using ftp and go to that path. Now i need to copy those files in the remote directory to my local server with the timestamp of all those files shouldnt be changed. ... (5 Replies)
Discussion started by: arunkumarmc
5 Replies

5. Shell Programming and Scripting

Can a script runned in local server access remote server?

Hi, Im creating a script that is supposed to run commands on remote server using sftp. My script is as below: #!/bin/ksh sftp remote_server mypassword cd /u08/mydir/allfiles mget * .. But this is what I got when I runned the script: Connecting to remote server...... (3 Replies)
Discussion started by: luna_soleil
3 Replies

6. UNIX for Advanced & Expert Users

Commands to copy a tar.gz file from a Remote Unix Server to Local Desktop.

Hi, Just wanted to know, how can I ftp/transfer/copy a (design.tar.gz) archive from a Unix Server (sdmc222.sdmc.cp-srv.com) which is at a remote location, to my Windows Desktop. Obviously, it is not possible at cmd prompt on my Windows using the following commands :- ftp... (3 Replies)
Discussion started by: marconi
3 Replies

7. Shell Programming and Scripting

Find match in two diff file - local srv and remote server

Perl Guru.... I need to compare two diff file (file1.abc will locate in current server and file2.abc will locate in remote server), basically the script will look for match in both file and only will send out email if there is no match and also give me list of unmatch and dups as well. So... (0 Replies)
Discussion started by: amir07
0 Replies

8. Shell Programming and Scripting

Transfer file from local unix server to remote server

want to remove this thread. thanks (2 Replies)
Discussion started by: indira
2 Replies

9. HP-UX

Transfer file from local unix server to remote server

want to remove the thread thanks (2 Replies)
Discussion started by: indira
2 Replies

10. Shell Programming and Scripting

FTP multiple files from remote server to local server

Hi, I am facing a weired problem in my FTP script. I want to transfer multiple files from remote server to local server everyday, using mget * in my script. I also, want to send an email for successful or failed FTP. My script works for file transfer, but it don't send any mail. There is... (2 Replies)
Discussion started by: berlin_germany
2 Replies
Login or Register to Ask a Question