Sponsored Content
Top Forums UNIX for Dummies Questions & Answers File listing from remote to local directory Post 302624073 by pavan_test on Sunday 15th of April 2012 05:58:54 PM
Old 04-15-2012
File listing from remote to local directory

Hello,

I have a file at remote server. I have to select only current day's files that are dropped on ftp server. The files do not have date or timestamp on them.

so I plan to get the file listing from remote server to the local server. Based on file listing date I can find out when the files are dropped. (by comparing with the current day's date)

I have a ftp script and I am using these commands to get the file listing date to the local directory.

Code:
ftp <host_name>
ftp <user>
ftp <password>
dir <dir>
200 PORT command successful
150 Opening ASCII mode data connection for file list
-rw-rw-r--   1 <uuu>  <kkk>   160384 Apr 13  19:38 walmart.txt
226 Transfer complete
ftp> lcd <local_dir>
ftp> dir walgreens.txt lcd
output ot local-file: lcd? y
200 PORT command successful
150 Opening ASCII mode data connection for file list
226 Transfer complete
ftp> bye

now I find lcd on my local directory,

Code:
-rw-r--r--    1 <usr>   <usr>              69 Apr 15 16:49 lcd

And when I do "vi lcd" (or "more lcd") I find this,

Code:
-rw-rw-r--   1 <uuu>  <kkk>   160384 Apr 13  19:38 walmart.txt

Can somone please tell me, after I get the file to local directory, how do I find out if the file is current day file using a korn shell script.

Thanks
pavan

Last edited by Scrutinizer; 04-15-2012 at 07:41 PM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. Solaris

[FTP]opying of file from remote to local machine

Hi All, i wannna copy a file from the remote machine to my local machine using FTP protocol. i have made a connection to the remote machine , then i used the "get" cmd to copy the remote file as below :-> ftp> get (remote-file) /home/aruba/opmtools/was50/Was5Install.doc (local-file)... (1 Reply)
Discussion started by: sonbag_pspl
1 Replies

2. UNIX for Dummies Questions & Answers

File System - Remote or Local??

Is there a way to find if the file systems mounted on a AIX/Linux box is local or remote? (1 Reply)
Discussion started by: Un1xNewb1e
1 Replies

3. Shell Programming and Scripting

Calculate the time difference between a local file and a remote file.

I m stuck with a issue. I need to calculate the time difference between two files.. one on the local machine and one on the remote machine using a script. Can any one suggest the way this can be achevied Thanks, manohar (1 Reply)
Discussion started by: meetmano143
1 Replies

4. HP-UX

How to execute a remote file with local command

Hello, I know this is somewhat strange, but please let me know if possible. I want to execute a program file in the remote machine with command on the local machine. Let me make things more clear. Suppose I have a cc on my local system and do not have that on the remote system. I want to use... (2 Replies)
Discussion started by: Veera_Raghav
2 Replies

5. Shell Programming and Scripting

FTP files from different directory from remote server to one directory in local

Hi All, I want to search for .log files from folders and sub folders in remote server and FTP them to one particular folder in the local machine. I dont want to copy the entire directory tree structure, just have to take all the .log files from all the folders by doing a recursive search from the... (3 Replies)
Discussion started by: dassv
3 Replies

6. UNIX for Dummies Questions & Answers

File Listing from remote to loca directory using SFTP

Hello, Using ftp i was able to get a directory listing to local directory. ftp - i <host_name> ftp <user> ftp <password> dir <dir> 200 PORT command successful 150 Opening ASCII mode data connection for file list -rw-rw-r-- 1 <uuu> <kkk> 160384 Apr 13 19:38 walmart.txt 226... (5 Replies)
Discussion started by: pavan_test
5 Replies

7. Shell Programming and Scripting

Replicate remote directory to local directory with ftp

I have system that generate files every 1 hours , i only have ftp connection from my local server to remote . $ ls -al -rw-r--r-- 1 water None 0 Feb 7 18:09 a.0800 -rw-r--r-- 1 water None 0 Feb 7 18:09 a.0900 -rw-r--r-- 1 water None 0 Feb 7 18:09 a.1000 is there any perl / php... (3 Replies)
Discussion started by: before4
3 Replies

8. Shell Programming and Scripting

Using expect to remote SSH and write to a local file

Hi Guys, So what I am trying to do is : Host A should do a SSH to Host B to F. Login to the remote host and gather the output of uptime and write to to a file in HostA. So by the end of the script, HostA should contain a file that contains the uptime output of Host B,C,D,E,F. Right now... (1 Reply)
Discussion started by: Junaid Subhani
1 Replies

9. Shell Programming and Scripting

File transfer from remote to local

Hi, I came across the scenario, that I need to copy files from the remote server to my local. The files in the remote server are created by another job and its keep on generating the files in that remote folder. We can't able to use SCP command and we're using SFTP to connect the server and... (3 Replies)
Discussion started by: Janarthan
3 Replies

10. Shell Programming and Scripting

Unable to ssh and list files in local directory from remote.

#!/bin/bash script_work_dir="/home/websys/TEST_dpi_42_file_trnsfer_engine/PORT22/script_work_area" script_config_dir="/home/websys/TEST_dpi_42_file_trnsfer_engine/PORT22/script_config" dpi_sourceServerList=$script_config_dir"/dpi_sourceServerList" dpi_srvr_42="rtm@1.1.1.1"... (8 Replies)
Discussion started by: sadique.manzar
8 Replies
AMRECOVER(8)							   AMANDA INDEX 						      AMRECOVER(8)

NAME
amrecover - Amanda index database browser SYNOPSIS
amrecover [ [ -C ] config ] [ -s index-server ] [ -t tape-server ] [ -d tape-device ] DESCRIPTION
Amrecover browses the database of Amanda index files to determine which tapes contain files to recover. Furthermore, it is able to recover files. In order to restore files in place, you must invoke amrecover from the root of the backed up filesystem, or use lcd to move into that directory, otherwise a directory tree that resembles the backed up filesystem will be created in the current directory. See the examples below for details. See the amanda(8) man page for more details about Amanda. OPTIONS
[ -C ] config Amanda configuration (default: DailySet1). -s index-server Host that runs the index daemon (default: localhost). -t tape-server Host that runs the tape server daemon (default: localhost). -d tape-device Tape device to use on the tape server host (default: /dev/null). COMMANDS
Amrecover connects to the index server and then presents a command line prompt. Usage is similar to an ftp client. The GNU readline library is used to provide command line history and editing if it was built in to amrecover. The purpose of browsing the database is to build up a restore list of files to be extracted from the backup system. The following commands are available: sethost hostname Specifies which host to look at backup files for (default: the local host). setdate YYYY-MM-DD Set the date (default: today). File listing commands only return information on backup images for this day, for the day before with the next lower dump level, and so on, until the most recent level 0 backup on or before the specified date is encountered. For example, if: 1996-07-01 was a level 0 backup 1996-07-02 through 1996-07-05 were level 1 backups 1996-07-06 through 1997-07-08 were level 2 backups then if 1997-07-08 is the requested date, files from the following days would be used: 1997-07-08 (the latest level 2 backup) 1997-07-05 (the latest level 1 backup) 1997-07-01 (the latest level 0 backup) Only the most recent version of a file will be presented. The following abbreviated date specifications are accepted: --MM-DD dates in the current year ---DD dates in the current month of the current year setdisk diskname [ mountpoint ] Specifies which disk to consider (default: the disk holding the working directory where amrecover is started). It can only be set after the host is set with sethost. Diskname is the device name specified in the amanda.conf or disklist configuration file. The disk must be local to the host. If mountpoint is not specified, all pathnames will be relative to the (unknown) mount point instead of full pathnames. listdisk [diskdevice] List all diskname settape [[server]:][tapedev|default] Specifies the host to use as the tape server, and which of its tape devices to use. If the server is omitted, but the colon is not, the server name reverts to localhost, the configure-time default. If the tape device is omitted, it remains unchanged. To use the default tape device selected by the tape server, the word default must be specified. If no argument is specified, or the argument is an empty string, no changes occur, and the current settings are displayed. If you need to change the protocol (tape:, rait:, file:, null:) then you must specify the hostname. settape localhost:file:/file1 You can change the tape device when amrecover ask you to load the tape: Load tape DMP014 now Continue? [Y/n/t]: t Tape device: server2:/dev/nst2 Continue? [Y/n/t]: Y Using tape /dev/nst2 from server server2. setmode mode Set the extraction mode for Samba shares. If mode is smb, shares are sent to the Samba server to be restored back onto the PC. If mode is tar, they are extracted on the local machine the same way tar volumes are extracted. mode Displays the extracting mode for Samba shares. history Show the backup history of the current host and disk. Dates, levels, tapes and file position on tape of each backup are displayed. pwd Display the name of the current backup working directory. cd dir Change the backup working directory to dir. If the mount point was specified with setdisk, this can be a full pathname or it can be relative to the current backup working directory. If the mount point was not specified, paths are relative to the mount point if they start with "/", otherwise they are relative to the current backup working directory. The dir can be a shell style wildcards. cdx dir Like the cd command but allow regular expression. lpwd Display the amrecover working directory. Files will be restored under this directory, relative to the backed up filesystem. lcd path Change the amrecover working directory to path. ls List the contents of the current backup working directory. See the description of the setdate command for how the view of the directory is built up. The backup date is shown for each file. add item1 [ item2 ... ] Add the specified files or directories to the restore list. Each item may have shell style wildcards. addx item1 [ item2 ... ] Add the specified files or directories to the restore list. Each item may be a regular expression. delete item1 [ item2 ... ] Delete the specified files or directories from the restore list. Each item may have shell style wildcards. deletex item1 [ item2 ... ] Delete the specified files or directories from the restore list. Each item may be a regular expression. list [ file ] Display the contents of the restore list. If a file name is specified, the restore list is written to that file. This can be used to manually extract the files from the Amanda tapes with amrestore. clear Clear the restore list. quit Close the connection to the index server and exit. exit Close the connection to the index server and exit. extract Start the extract sequence (see the examples below). Make sure the local working directory is the root of the backed up filesystem, or another directory that will behave like that. Use lpwd to display the local working directory, and lcd to change it. help Display a brief list of these commands. EXAMPLES
The following shows the recovery of an old syslog file. # cd /var/log # ls -l syslog.7 syslog.7: No such file or directory # amrecover AMRECOVER Version 2.4.2. Contacting server on localhost ... 220 localhost AMANDA index server (2.4.2) ready. Setting restore date to today (1997-12-09) 200 Working date set to 1997-12-09. 200 Config set to DailySet1. 200 Dump host set to this-host.some.org. $CWD '/var/log' is on disk '/var' mounted at '/var'. 200 Disk set to /var. /var/log WARNING: not on root of selected filesystem, check man-page! amrecover> ls 1997-12-09 daemon.log 1997-12-09 syslog 1997-12-08 authlog 1997-12-08 sysidconfig.log 1997-12-08 syslog.0 1997-12-08 syslog.1 1997-12-08 syslog.2 1997-12-08 syslog.3 1997-12-08 syslog.4 1997-12-08 syslog.5 1997-12-08 syslog.6 1997-12-08 syslog.7 amrecover> add syslog.7 Added /log/syslog.7 amrecover> lpwd /var/log amrecover> lcd .. /var amrecover> extract Extracting files using tape drive /dev/null on host localhost The following tapes are needed: DMP014 Restoring files into directory /var Continue? [Y/n]: y Load tape DMP014 now Continue? [Y/n/t]: y set owner/mode for '.'? [yn] n amrecover> quit 200 Good bye. # ls -l syslog.7 total 26 -rw-r--r-- 1 root other 12678 Oct 14 16:36 syslog.7 If you do not want to overwrite existing files, create a subdirectory to run amrecover from and then move the restored files afterward. # cd /var # (umask 077 ; mkdir .restore) # cd .restore # amrecover AMRECOVER Version 2.4.2. Contacting server on localhost ... ... amrecover> cd log /var/log amrecover> ls ... amrecover> add syslog.7 Added /log/syslog.7 amrecover> lpwd /var/.restore amrecover> extract Extracting files using tape drive /dev/null on host localhost ... amrecover> quit 200 Good bye. # mv -i log/syslog.7 ../log/syslog.7-restored # cd .. # rm -fr .restore If you need to run amrestore by hand instead of letting amrecover control it, use the list command after browsing to display the needed tapes. # cd /var/log # amrecover AMRECOVER Version 2.4.2. Contacting server on localhost ... ... amrecover> ls ... amrecover> add syslog syslog.6 syslog.7 Added /log/syslog Added /log/syslog.6 Added /log/syslog.7 amrecover> list TAPE DMP014 LEVEL 0 DATE 1997-12-08 /log/syslog.7 /log/syslog.6 TAPE DMP015 LEVEL 1 DATE 1997-12-09 /log/syslog amrecover> quit The history command shows each tape that has a backup of the current disk along with the date of the backup, the level, the tape label and the file position on the tape. All active tapes are listed, not just back to the most recent full dump. Tape file position zero is a label. The first backup image is in file position one. # cd /var/log # amrecover AMRECOVER Version 2.4.2. Contacting server on localhost ... ... amrecover> history 200- Dump history for config "DailySet1" host "this-host.some.org" disk "/var" 201- 1997-12-09 1 DMP015 9 201- 1997-12-08 1 DMP014 11 201- 1997-12-07 0 DMP013 22 201- 1997-12-06 1 DMP012 16 201- 1997-12-05 1 DMP011 9 201- 1997-12-04 0 DMP010 11 201- 1997-12-03 1 DMP009 7 201- 1997-12-02 1 DMP008 7 201- 1997-12-01 1 DMP007 9 201- 1997-11-30 1 DMP006 6 ... amrecover> quit ENVIRONMENT
PAGER The ls and list commands will use $PAGER to display the file lists. Defaults to more if PAGER is not set. AUTHOR
Alan M. McIvor <alan@kauri.auck.irl.cri.nz> SEE ALSO
amanda(8), amrestore(8), readline(3) Alan M. McIvor 29 November 1996 AMRECOVER(8)
All times are GMT -4. The time now is 06:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy