Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I was willing to use sftp for tranferring files from one server to another remotely using crontab. For that I am using expect instead of creating certificates for ssh. Now problem is with expect when I get the files to my local machine then I have to run some commands there on that files like moving it/renaming it. Now I cant use those shell commands on that expect prompt, not sure though. So have to use another script for those. Is there any way possible to put those commands in same script so that all happens at the same time.
wrapping expedct around this is a pretty horrible point to end up at. i'd suggest using sshfs to just mount it as if local over ssh and then just copy however you see fit.
but rsa key authentication is so so so much simpler than learning tcl for expect. what's your motivation for doing this? i'm totally lost.
As to what you're having problems with i'm really unclear, can you define a use case to show how you get stuck?
Hi,
As these are all local servers thats why I didn't thought of ssh way. Simply run expect to automatically provide password at periodic times using crontab to get files from remote server. Problem is, I was using two scripts; one for sftp to get the files, second one for copy and change ownership of those files which I want to be combined, which can done
as below
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,197
Rep:
I'm surprised no one has mentioned the security issues around exposing a password in a script.
Setting up an ssh key pair allows you to do what you want securely with just a few lines. I've done this when I'm running backup scripts. The backup script has to run as root, but I don't want root logins even with key pairs. So I have the script on one machine accessing another machine with a command embedded in ssh embedded in an su: `su - backup -c "ssh server2 \"mt status\""` for example. The user "backup" has key pairs set up, and it just works. Yours would seem to just require the simple `scp user@server1.x.x.x:/var/scripts/tests.txt /usr/local/apache` followed by the chown.
I've only used expect where I'm dealing with a menu driven system like a library catalog system (before they all went web), and there really wasn't an alternative there.
I have been fighting the same issue, I had my scripts working perfect with expect and interact, until I went to cron. My problem is that I have to mget files and then rename each one to a new location. This would be a pain in an expect script. So here is what I did, maybe it would work for you.
I enabled rexec and issued a remote command to execute the script. expect/interact works through rexec. You can even setup a cron job to execute the remote command.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.