ftping a file based in the size


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers ftping a file based in the size
# 1  
Old 02-19-2008
ftping a file based in the size

Hi,

I want to connect to a remote machine using FTP, check for the size of a file there. If it is 0 bytes, then there is no need to ftp else i have to ftp the file. Any help will be highly appreciated.
# 2  
Old 02-19-2008
why don't you use ssh and scp rather than ftp ?
# 3  
Old 02-19-2008
can u please tell me how do i connect using ssh?? like in ftp , we use something like ftp <ip address>. How is this done in ssh?? i believe it has some options here for login and passwords. Please help
# 4  
Old 02-19-2008
I believe you have ssh keys generated.

ssh <user@remote_host> ls -l <filename_with_absolutepath>
# 5  
Old 02-19-2008
Thank dude.One more question though.
This keeps prompting for a password.. Is there any way by which the password can also be passed? Or is there something like in ftp scripts where we can quote the password?
# 6  
Old 02-19-2008
Quote:
Originally Posted by vikas.rao11
Thank dude.One more question though.
This keeps prompting for a password..
The reason is you haven't "exchanged the keys" as manikantants has "believed". ssh is a system where you can designate machine/user combinations as "trusted", so that they won't need a password. Do the following:

i assume you use user a on machine a to connect to machine b as user b. You don't want to need passwords if user a@a connects to b@b.

1.) log on to machine a as user a. Enter "ssh-keygen" to generate a key and follow the instruction. Do NOT enter any password when you are asked for it. Just press <ENTER>.

2.) You now have a directory "~/.ssh" with some files in it, depending on what type of key you have selected with ssh-keygen. In case you selected "rsa" in step one there would be two files "id_rsa" and "id_rsa.pub". NEVER TOUCH THE FILE id_rsa! Open the file id_rsa.pub with some editor or "cat" it to the terminal.

3.) Log on to machine b as user b and - if there is no directory "~/.ssh" - create a key there (Step 1). You won't need the key, but it creates the directory structure (~/.ssh) with the correct permissions as well.

4.) If there is no file "authorized_keys" create it, otherwise open it with a text editor. Cut and paste the content of of the file id_rsa.pub from the other machine to the end of this file. CAUTION: this is ONE long line, if you use screen-cut-and-paste you might get several lines of text delimited by newlines. Remove the newlines to get one long line back in this case. Save the file.

5.) From now on you can log on or transfer files without giving any password as user a@a to user b@b, but not the other way round. If you log on as user b@b you will have to present a password if you want to execute commands as user a@a. If you want to remove the necessity for passwords there too you will have to do the described process in the other direction again. CAUTION: you have to create a key (Step 1) ONLY ONCE, creating a new key makes all the entries in other authorized_key-files invalid.

I hope this helps.

bakunin
# 7  
Old 02-19-2008
Thanks a lot.

I guess i am missing something here. Somehow i am still being asked for the password.

here is what i have done

1. ssh-keygen
2. <ENTER>
3. <ENTER>
4. Log on to remote machine B.
5. ssh-keygen
6. Create a file called authorized_keys and paste the row from id_rsa.pub in client machine A and save it.


I am still being asked for the password.. please help
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

File Size Split up based on Month

Hi, I have a directory in Unix and there are folders available in the directory. Files are created on different month and now i have a requirement to calculate size of the folder on month basis. Is there any Unix command to check this please?? Thanks (6 Replies)
Discussion started by: Nivas
6 Replies

2. Shell Programming and Scripting

Split the File based on Size

I have a file that is about 7 GB in size. The requirement is I should split the file equally in such a way that the size of the split files is less than 2Gb. If the file is less than 2gb, than nothing needs to be done. ( need to done using shell script) Thanks, (4 Replies)
Discussion started by: rudoraj
4 Replies

3. Shell Programming and Scripting

Split file based on file size in Korn script

I need to split a file if it is over 2GB in size (or any size), preferably split on the lines. I have figured out how to get the file size using awk, and I can split the file based on the number of lines (which I got with wc -l) but I can't figure out how to connect them together in the script. ... (6 Replies)
Discussion started by: ssemple2000
6 Replies

4. Shell Programming and Scripting

Split a file based on pattern and size

Hello, I have a large file (2GB) that I would like to split based on pattern and size. I've used the following command to split the file (token is "HELLO") awk '/HELLO/{i++}{print > "file"i}' input.txt and the output is similar to the following (i included filesize in KB): 10 ... (2 Replies)
Discussion started by: jl487
2 Replies

5. Shell Programming and Scripting

Split file based on size

Hi Friends, Below is my requirement. I have a file with the below structure. 0001A1.... 0001B1.. .... 0001L1 0002A1 0002B1 ...... 0002L1 .. the first 4 characters are the sequence numbers for a record, A record will start with A1 and end with L1 with same sequence number. Now the... (2 Replies)
Discussion started by: diva_thilak
2 Replies

6. Shell Programming and Scripting

Moving a file based on size

hello, I am creating a script that is going to scan the contents of a directory, and if it finds a certain DocumentName that is a certain size (The example, DocumentName and a size of 8777) If this file exists, it needs to be moved to a directory for later removal/processing..anyone have... (7 Replies)
Discussion started by: jeffs42885
7 Replies

7. Shell Programming and Scripting

Need to move a file based on size

Hi All, I have some files in a directory. If the file size is 0 i want to move the file to new directory using unix script. Can anyone help me in this regard Thanks Vinny (4 Replies)
Discussion started by: vinny81
4 Replies

8. UNIX for Dummies Questions & Answers

Copy a file based on the size-Urgent

Hi, I need unix code to check the size of a file. for example if the size of the file in A folder is more than 1BM, then i have to move that particular file in to B folder whenever I run that particular script. regards, Srinivas. (7 Replies)
Discussion started by: vysrinivas
7 Replies

9. UNIX for Dummies Questions & Answers

Size limit for FTPing file

Is there any size limit for FTPing file from one unix system to another? (6 Replies)
Discussion started by: swarup2008
6 Replies

10. UNIX for Dummies Questions & Answers

Mail based on file size

Hi Friends, i am trying to write a shell script which will check for the logfile size. if the content of the logfile is wc -l >=1 then send mail with log file as attachment.else do nothing. i'm trying the below code can any one help on this if ] then (echo "`cat... (2 Replies)
Discussion started by: rajendragora
2 Replies
Login or Register to Ask a Question