Sponsored Content
Top Forums Shell Programming and Scripting How to get user to choose files to be copied to FTP server? Post 302845055 by Gouda on Tuesday 20th of August 2013 04:27:02 PM
Old 08-20-2013
How to get user to choose files to be copied to FTP server?

Hey all. I'm writing a script to automatically login to a router, change directories to where crashfiles are located, then listing all files in that directory. This is where I'm at so far and wish to have some user interaction to choose the files.

What I am trying to do is list the files and get the user to choose which files to be copied over to the FTP server including a file name change which will also include adding a case number to the beginning of the file to be copied as part of the file name change sequence.

List files
Ask users which files to be copied
Ask user for case number(enter case number and append to front of original file name. This will not be changing the name on the current server but changing the file name during the copying process.)
And then copy ALL files chosen over to the FTP server with the new file name.

What is the best way to do this?
This is what I got so far.

Code:
expect "#"


send "cd /md\r"
expect "#"
send "dir\r"
set files ""
expect {
        -re "(\[^\n]+)\n" {
                set line [ string trim $expect_out(1,string) ]
                if { [llength $line ] > 7  } {
                  send_user "Hey I found a file its called : [ lindex $line 8 ]\n"
                  lappend files [ lindex $line 8 ]
                }
                exp_continue
        }
        "#" {}


}



foreach f $files {
send_user "$f\n"

}




interact

and the output when I run script is as follows

Code:
[local]#cd /md
Current directory is now /md
[local]#dir
Contents of /md/
total 150372
drwxrwxrwx  2 root  0       512 Jun 28 21:52 issu
-rw-r--r--  1 root  0   1048444 Jun  5 17:02 loggd_ddbg.bin
-rw-r--r--  1 root  0   1048444 Jun  5 17:02 loggd_dlog.bin
-rw-r--r--  1 root  0  57773225 Jun  5 17:02 rdb_crash.out
-rw-r--r--  1 root  0    234581 Aug 19 20:49 file.cfg
-rw-r--r--  1 root  0  16777216 Jun 28 21:52 rtdb.sav
[local]#Hey I found a file its called : issu
Hey I found a file its called : loggd_ddbg.bin
Hey I found a file its called : loggd_dlog.bin
Hey I found a file its called : rdb_crash.out
Hey I found a file its called : file.cfg
Hey I found a file its called : rtdb.sav
issu
loggd_ddbg.bin
loggd_dlog.bin
rdb_crash.out
file.cfg
rtdb.sav

[local]#


Last edited by Gouda; 08-20-2013 at 08:29 PM..
 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

how to know how many user's connected to ftp and http server

i need to write a program to know how many users are presently connected to my ftp server and http server . i need to keep a count of this and this count should be available to other different software . how to make this GLOBAL so that other softwares can access this count value (7 Replies)
Discussion started by: hariprasad
7 Replies

2. 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

3. Shell Programming and Scripting

Dowloading a File from FTP Server to a local Server where User Id's are different

Hi, The Setup is like this. I'm connecting to Unix machine from my local machine. After connecting to Unix M/c, i need to connect FTP server. Am successful in connecting to FTP server, but am not able to download the file from the ftp server to my local machine. I have different user id's and... (1 Reply)
Discussion started by: ranjith_taurean
1 Replies

4. HP-UX

FTP user information on destination server

Could any one please tell me how to check the ftp users information on the destination server ( Hp-UX ) ? Source server used to do FTP to my server ( that is destination server ) . Now , he is getting error that login is incorrect and unable to login into destination server . Please tell me how to... (3 Replies)
Discussion started by: randhir
3 Replies

5. 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

6. Shell Programming and Scripting

script for to take files from FTP server to UNIX server and Unzipped that files

script for to take files from FTP server to UNIX server and Unzipped that files (1 Reply)
Discussion started by: sunilamarnadh
1 Replies

7. Shell Programming and Scripting

Check files copied from remote server

There is a process which copy files form unix a to unix b I would like to check whether all files copied from a to b or not ,and list which are the missing files. Is there a command to check like that (3 Replies)
Discussion started by: lalitpct
3 Replies

8. Red Hat

Files copied to FTP server not shown

I had copied 2 files to an FTP server which I deployed on my RHEL 5.8 server. The ownership I kept for the files are for the user, ftp. But, I do not see the files on the FTP location using either accessing through Windows explorer or the browser. The ftp location is ftp://10.101.17.80/incoming.... (7 Replies)
Discussion started by: RHCE
7 Replies

9. Solaris

FTP-ing files from Windows server to UNIX server

I need to transfer files from a Windows server to the Unix server and have to run some shell script on it to get the required output. Is it possible to transfer files from Windows server to unix server through any shell script? If so can you please help me with the details. Thanks in... (8 Replies)
Discussion started by: ssk250
8 Replies
uudemon(4)						     Kernel Interfaces Manual							uudemon(4)

NAME
uudemon.admin, uudemon.cleanu, uudemon.hour, uudemon.poll - Administrative shell scripts for polling remote systems, cleaning up spool directories, reporting status to the system administrator, and routine invocations of the uuxqt and uusched daemons SYNOPSIS
These shell scripts reside in the following directory: /usr/lib/uucp DESCRIPTION
All the scripts can be run from the command line or can be run automatically by the cron daemon. To automatically run the scripts, remove the comment character (#) from the beginning of the relevant line in the /var/spool/cron/crontabs/uucp file. This script reports status to the system administrator. It issues the uustat command to find out the status of uucp jobs. It mails the results to the uucp login ID. The script may be modified to send mail to any login ID such as the uucp administrative login ID (uucpa) or root. This script cleans up the /var/spool/uucp and /var/spool/uucppublic directories by running the uucleanup command. The uucleanup com- mand is run with the following parameters: -C7, -D7, X2, -o2, -W1. This script runs the uusched and uuxqt daemons in the background. This script polls the systems listed in the /usr/lib/uucp/Poll file. The uudemon.poll script should be scheduled before the uudemon.hour script. This allows uudemon.poll to create any command files before cron runs the uudemon.hour script. FILES
Contains the uudemon.admin, uudemon.cleanu, uudemon.hour and uudemon.poll files. Contains the uucp file. RELATED INFORMATION
Commands: cron(8), uucleanup(8), uusched(8), uuxqt(1) Files: /usr/lib/uucp delim off uudemon(4)
All times are GMT -4. The time now is 09:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy