scp automation


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers scp automation
# 1  
Old 12-28-2009
scp automation

my source folder is :/tmp/util
of server : pyxis-as2

and target folder is :/apps/prodapp/util/
of server : pyxis-db2

i am trying to do a copy from source to target through SCP

is there any way that I can kick shell script from pyxis-as2 once any single file get loaded into /tmp/util

my scp script is :
Code:
scp -r /tmp/util/*.csv user@pyxis-db2:/apps/prodappl/util/

plus how should i bypass the password into script

any help will be highly appreciated
# 2  
Old 12-28-2009
Do you need to copy them the instant they appear, or is a certain interval OK? For the later, run your command via cron every n minutes. For the former you'll need a script that always runs checking the dir, or hook into the process that puts the file there (eg by watching the FTP transfer log)

As for the authentication bit: don't pass the password along, use public-key authentication instead.
# 3  
Old 12-29-2009
scp automation

thanks pludi,sorry to little troubling you.

Thanks for advicing for using public-key authentication, I am able to test the public-key authentication.This part i am able to handle. There was step by step process for adding public-key authentication. I am able to do,

I want to do a file transfer as soon as any file get entered into a particular folder.

I am not sure about unix cron program , as I am not a fully unix guys.

My requirement is very simple like a trigger in oracle.

The reason I am looking, as Unix side, application server is located in different box and database in different box. I have built a page (web page) which take the file from user desktop and upload in server in a particular folder. This folder is always fix. Now I have a loader program which requires datafile somewhere in server where DB is there. I could not able to do , and just cheked with DBA they told through scp i can copy, a scp copy scrtipt is working fine , but that requires manual kick-off. This is where I am looking automation, the event should be as soon any file get entered into this folder. If you mention 1 min is requires in cron then I believe it must have options for 1 sec too. But I am not sure , dose Unix handle file transfer or do they have locking.


any input and any thread /insight for cron is highly apprecaited.
# 4  
Old 12-29-2009
It's not quite that simple. A trigger in a RDBMS is executed as soon as it registers a certain event (row update/insert/..., ...). What the RDBMS is for a database is the filesystem for a file, but I know of no system where it can trigger an executable. So you'll have to find a different approach.

One option might be cron. The limitation with cron is that it's resolution is one minute max, meaning your file would be copied with a maximum delay of 1 minute. If that's enough for you, fine, if not we'll have to find something different.

Another option might be to create a small daemon (like sendmail or cron) that watches a certain directory and copies any file that hasn't changed it's size during the last 2 seconds.

Or, third option, you have some kind of log file what registers when a file starts uploading, and when the upload finished. As soon as it's done start the copy process. Basically a variation of the above.

Finally, if your web page can register an finished upload, use it to start the upload via system() or something similar.
# 5  
Old 12-29-2009
As said, do a daemon or cron to watch and update.

Some more suggestions ( not solution ):
1. set up passwordless login,
2. use -B option ensure endless wait does not happens
3. check whether rsync fits for you.
4. follow the ideas by pludi, and implement a system, and get back to us.
# 6  
Old 12-30-2009
if you need for connecting from one server to another server without password, you can use RSA alghorithm.
it use public key and private key. it is secure also.
Good luck.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

scp Automation

Hi, I have a requirement to automate SCP command. I have to write the scp command in server1 to copy file from server2 and paste it in server3. I will be passing server2 and server3 as variables. Pls suggest. (1 Reply)
Discussion started by: usrrenny
1 Replies

2. UNIX for Dummies Questions & Answers

CUPs automation

A little background information: We are a company that uses Sharp MFP devices for everyone to print on. We have a lot of MAC BYOD devices. All printing is done through a product called PaperCut which is ran on a Windows 2008 R2 server. Sharp charges our company for each print job done in... (1 Reply)
Discussion started by: jdmorecraft
1 Replies

3. Shell Programming and Scripting

Small automation

Frequently we need to stop or start services on Linux systems. For exmaple : To start or stop vsftpd daemon # /etc/init.d/vsftpd start or # /etc/init.d/vsftpd stop Following script will check the vsftpd service and if it is running, it will be stopped or vice-versa. # cat... (5 Replies)
Discussion started by: snjksh
5 Replies

4. UNIX for Advanced & Expert Users

Need help in automation

Hi, I wanted to automate the scp command where i do not want to enter the password each time. So thought of using expect command. Script is executing without any issues but files are not copied to remote server. Can any one help me? Below is my shell script.. #!/bin/ksh ... (6 Replies)
Discussion started by: balasubramani04
6 Replies

5. Shell Programming and Scripting

scp automation

hi there , i want to use the scp to transfer the file from one machine to another machine non-stop. i have put it in a .sh file. but everytime i run it and it prompts me to input password. pc3@pc3-desktop:~/Documents$ ./sample3.sh pc-main@192.168.1.117's password: screenshot.jpg ... (4 Replies)
Discussion started by: Ericyue
4 Replies

6. Shell Programming and Scripting

Tar automation

Hi, i'm new in shell programming, i would like to archive automatically all my log files at the end of each month. My files have this format : 2011.07.log1 2011.07.log2 ... 2011.08.log1 2011.08.log2 ... etc I would like to have an idea about how to do this. Thanks. (2 Replies)
Discussion started by: thedriver
2 Replies

7. Shell Programming and Scripting

Scripting for automation

Hi, I would like to know about a automated script which would collect data on a regular day to day basis at a particular time and stores it in a defined path for business analysis. Any help on this is highly appreciable!! Thanks Sara (6 Replies)
Discussion started by: sara23
6 Replies

8. Shell Programming and Scripting

UNIX automation

Hello People, I have an outstanding issue with me I have 5 files at location /usr/abc called 1.DE 1.TXT 2.DE 2.TXT 3.DE 3.TXT 4.DE 4.TXT 5.Fe.ok My work involves few manual process like transfer 1.DE 1.TXT and 5.Fe.ok to /usr/dob location and run one script(for example -... (42 Replies)
Discussion started by: j_panky
42 Replies

9. Shell Programming and Scripting

Help need for automation of su command

Hi All! I need to automate the su command using expect script.Suppose I login as a user A , I need to change the user to oracle using the su oracle command and execute the command "sqlplus -ver". I tried writing a expect script for the same , but can't figure out the reason it is not working. ... (1 Reply)
Discussion started by: nua7
1 Replies

10. Shell Programming and Scripting

Help in automation...

Hi All, I need to run the same command on many servers. I am using ssh for the same. Following is the script that I am using to fire the same command on multiple machines. #!/bin/bash # Linux/UNIX box with ssh key based login #SERVERS="iqmevrick,iqmango" # SSH User name USR="root" #... (1 Reply)
Discussion started by: nua7
1 Replies
Login or Register to Ask a Question