Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Hello, I need to copy every hour some files from local directory to remote vis sftp.
I open 1 session for all files and copy them to remote host with mput.
But if the copying would be wrong - for example connection would be lost. How I can know abouit it in the Bash.
First, in timed things like this, you might consider building this as a cron job. It can make the script less complex and gets rid of the need of another programming running all of the time.
Now then, to answer your actual question. After:
sftp -b /dev/fd/0 $TARGET_USER@$TARGET_HOST>>$FTPLOG 2>&1<<EOT
try checking the exit status of sftp. Like:
if [ $RET -eq 0 ]
"$?" is the return code for the previously executed process. Usually, if it's zero, everything is fine.
Yes, it may be use when the connection will fail, but if while during
sftp session working on remote computer and there script could'nt copy some files or some permissions incorrect. And that its why sftp will give
TRUE but files didn't copy to remote host. How I can see that all files copyed successfully?
Then you can't do it... in SFTP
Look, you can either send & chmod all the files in one go, then use an ssh session to do a remote 'ls -l' (assuming you can ssh in), or you check each operation as you go.
Another way that might do what you want with one session would be to use one of the Perl SSH modules. I think you'd be able to do an scp within the ssh session, as well as the chmod cmd, and check as you go.