FTP Program


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting FTP Program
# 1  
Old 12-30-2011
FTP Program

Hi all,

I have a script in 5 servers that looks like this: (collector.sh)
Code:
#!/usr/bin/sh

cat /var/log/messages | grep -i nscmd > nscmd_output
cat /var/log/messages | grep -i sshd | grep -i accepted > sshd_output
sleep 3
cat nscmd_output sshd_output | sort > user_activity
sleep 2
echo
echo "User Logs for Backup-Server:"
echo "----------------------------"
echo
cat user_activity
echo
echo "User History for Backup-Server:"
echo "-------------------------------"
echo
cat .bash_history
echo

The script will collect all the user activity logs from /var/log/messages and as well as the contents of the .bash_history and will put the printed output into /tmp/ directory.

Cat somebody help me how to create a script that will connect to each server through SSH, then execute the script, then get the logs (thru ftp) after the execution of collector.sh, and put all the generated logs from each server under /tmp/ directory of the main server (Server1)

Let's say, the script will be deployed in Server1, so once I executed it, it will first execute the the collector.sh within its self, and then perform the same actions on each server. So that in Server1 /tmp/ directory I have an output of:
Code:
collector_output_server1.log
collector_output_server2.log
collector_output_server3.log
collector_output_server4.log
collector_output_server5.log


Please help and advice,


Best regards,
rymnd_12345
# 2  
Old 12-30-2011
Hi,

ssh may be used to execute a single command on the remote server in the form:

Code:
ssh user@remote_server command

see man ssh for further info on this.

If ssh remote server is available, my advice is to use scp to copy files from remote servers to local server.

A pseudo-script algrithm may look like:
Code:
for remote_server in <server1> <server2> <...>
do
   ssh $user@${remote_server} /path/to/collector.sh
   scp $user@${remote_server}:/path/to/collector_output.log /localpath/to/collector_output_${remote_server}.log
done

Using ssh key-based authentication is *STRONGLY* advisable in order to keep script simple.

see ya
fra
# 3  
Old 12-30-2011
Hi frappa,

Thanks for your advice!


Br,
rymnd_12345
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl program get a response before the program quits

I created a program, so a kid can practice there math on it. It dispenses varies math problems and the kid must input an answer. I also want it to grade the work they have done, but I can't find the best place for it to print out the grade. I have: if ( $response =~ m/^/ ) { $user_wants_to_quit... (1 Reply)
Discussion started by: germany1517
1 Replies

2. UNIX and Linux Applications

Need a FTP SERVER Program FREE

I need a FTP SERVER program for using in ubuntu, Do you know any for free? ps: there will be no internet connection so, vsftp will not work. need a tool (like filezilla but filezilla has no server version for unix ubuntu) that has to be installation package to extract in it. (6 Replies)
Discussion started by: F@NTOM
6 Replies

3. UNIX for Dummies Questions & Answers

Program: How to FTP logs from a Server to Desktop

Hi guys, Good day! Anyone there could suggest on how can I create a program that will get (ftp) the logs I need from a remote Server (running in Linux) into my Desktop (running in Windows 7). For Perl program suggestions, FYI that I'm using Active Perl version. The reason why I need this one is... (2 Replies)
Discussion started by: rymnd_12345
2 Replies

4. UNIX for Dummies Questions & Answers

Which program can I use for blocking unauthorized access via/ssh/ftp

Hi, I need to install a program on my Centos 5.3 server that will block unauthorized ssh/ftp access attempts. The two features I require is that I should be able to configure the program to block the IP of the intruder after a a certain amount of access attempts and that it should display a... (3 Replies)
Discussion started by: mojoman
3 Replies

5. UNIX for Dummies Questions & Answers

Script to open program and send/execute command in program

Hi, i want to write a script that executes a program (exec?) . this program then requires a filename as input. how do i give it this input in the script so the program will be complete run and close by the script. e.g. exec prog.exe program then asks for filename "enter filename:"... (1 Reply)
Discussion started by: tuathan
1 Replies

6. Programming

C FTP program

Hi, Can somebody help me with this problem. I was ask to make a C Program that can FTP file file both downloading and uploading file in remote server. How can I do this, or is there any FTP library I can use for this one. I am using HP Unix 11.0 (1 Reply)
Discussion started by: cjediknight
1 Replies

7. Shell Programming and Scripting

ftp files from Unix to Windows through shell program

Hi, I made a shell script to allow user to ftp file to windows shared drive. Here is part of my code within my shell script: /usr/bin/ftpmtc $usr $pswd $jobno Within 'ftpmtc': #ARGUMENT: USER,PASWD,JOBNO,VER,LOG_DATE,$$ $UCB/echo "user $1 $2" > $inst_file $UCB/echo "cd prod" >> $inst_file... (7 Replies)
Discussion started by: whatisthis
7 Replies

8. UNIX for Dummies Questions & Answers

recommendation please. Unix base ftp program

in win32 platform, i can easily find some GUI based ftp application like cuteFtp, WsFtp and etc which provides GUI + resuming download. pls recommend me some similar application which runs on Sun Solaris sparc 8. hopefully it is free. thank you very much. (1 Reply)
Discussion started by: champion
1 Replies

9. UNIX for Dummies Questions & Answers

ftp program

does anybode know about a ftp program to be run under unix like (for example) ws_ftp.exe and where to get it? Want to run it on a (remote) server... Thanks! (3 Replies)
Discussion started by: paost712
3 Replies

10. Programming

usage of ftp in C program

thank you of your help my application system is : windows 2000 pc --- HP unix minicom ---- windows NT I am programming with C language on HP unix minicom , I want to get files with ftp command from windows 2000 pc to HP unix minicom in my program, and also put files with ftp command... (1 Reply)
Discussion started by: bdyjm
1 Replies
Login or Register to Ask a Question