Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
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.
Hi
I want a shell script that copies user generated reports from production to DR. AND also report generated in DR move the scripts from DR location to prod location. I tried my own way it's not working.
Code:
*#!/bin/sh
file1=user1@domain2.com:/path1/file1.txt (completePath to file1.txt)*
file2=user1@domain2.com:/path2/file2.txt (completePath to file2.txt)*
files=( ${file1} ${file2} )
scp ${files[@]} /home/path3*
Please use CODE tags when posting code. And is this the EXACT SCRIPT you're using?? Because there are several issues with it...can you tell us what it's not doing? Because just saying "it's not working", gives us nothing to go on.
To start:
Your script should start with #!/bin/bash for a bash script, but /bin/sh may work fine too....but the * in front of it????
Your file variables contain special characters (The @, :, and /), and there is no comment after the "file1.txt"...so the entire (completePath to file1.txt)* is being put INTO that variable too
The "files" array (ASSUMING you want an array here?) isn't defined correctly. Syntax is "array=( [XX]=<value> [XX]=<value> . . . )"
You aren't looping through the array to actually perform the SCP.
The "/home/path3*" isn't going to work. Needs to have a trailing "/home/path3/*" (bad), or "/home/path3" (correct)
Hi
I want a shell script that copies user generated reports from production to DR.
AND also report generated in DR move the scripts from DR location to prod location.
You'll need to back up a few steps. FTP should never, ever be used any more for transfer over the Internet. With FTP all your login credentials (username and password) as well as the data are transmitted unencrypted. Your machines will get compromised using that method. If you invest now in learning the right way, you will save a lot of effort by avoiding cleanup later. Not only that, the correct methods for file transfer will be less effort to implement.
As already suggested, rsync is a good option as it connects over SSH. Alternately, you can use plain SFTP, that also connects over SSH and has a batch mode which is useful for automation. SFTP fits into scripts in a way somewhat similar to FTP, but with the difference that it can actually be secure.
Either way, SFTP or rsync, your second step will be to set up key-based authentication over SSH so that can be the basis of your transfer. The first step, and top priority, should be decommissioning the FTP daemon.
i tried this ... to transfer of generated reports from from prod to dr server. anyone can sort it
Code:
#!/bin/sh
ftpuser="userid"
ftppass="passord"
ftpdest="destination server name"
ftpdate="date+%d"
outdir="home server path"
ftppath="destination server path"
log_dir="log directory path"
cd $out_dir
for ftpfile in 'ls'
do
echo"open ${ftpdest}
user ${ftpuser} ${ftppas}
asci
put ${ftpfile}
bye " | ftp -i -n -v >> ${log_dir}/log_${filedate}
done
Again, as you were asked before, put your code in CODE tags. Also, asking "anyone can sort it" is fairly rude, considering you never answered the first questions about your initial script. You're essentially asking us to write your script for you, and not even telling us what problem(s) you're having, message(s)/error(s) you're seeing, or even what version/distro of Linux you're using. And you've even gone back and edited your original question and changed what it said.
Again, its been suggested that you use rsync; you were given a link to a page with a sample script on it, which could have been easily modified to do what you're after. And you've only posted a second script that you copied from somewhere, without giving us any details. If you don't provide details, tell us what you're seeing/where, or even answer questions when asked, there is ABSOLUTELY NOTHING we can do to help you.
Again, as you were asked before, put your code in CODE tags. Also, asking "anyone can sort it" is fairly rude, considering you never answered the first questions about your initial script. You're essentially asking us to write your script for you, and not even telling us what problem(s) you're having, message(s)/error(s) you're seeing, or even what version/distro of Linux you're using. And you've even gone back and edited your original question and changed what it said.
Again, its been suggested that you use rsync; you were given a link to a page with a sample script on it, which could have been easily modified to do what you're after. And you've only posted a second script that you copied from somewhere, without giving us any details. If you don't provide details, tell us what you're seeing/where, or even answer questions when asked, there is ABSOLUTELY NOTHING we can do to help you.
Hi
it shows ksh: syntax error: 'for' unmatched
i was not rude to ask you such question. my script was not copied from some where else and it was done my me. if you wish to reply then its good or else no need it seems.
You were not rude for asking a question, but when you:
You ignored questions when asked
You provided no details when asked
You ignored the CODE tags when asked (twice)
You edited your first post, removing the script and changing it, making it hard for anyone to keep track of what you're asking about
And now you post "if you wish to reply then its good or else no need it seems.", after I tried to help and answer your questions, line by line, in my first reply, and following that up with "anyone can sort it". Those things are a bit rude, yes.
Quote:
Originally Posted by Preeti mohanty
my script was not copied from some where else and it was done my me.
..five years ago. The only detail you've now provided is that you're getting an unmatched "for"....which script is this in, the one you FIRST posted, or the one you edited/posted again? Guessing the second, and if it stands as you posted it, you have two unmatched double-quotes on different lines, and (since no CODE tags were used), the spacing/indention is impossible to see.
Again...rsync does what you're after, better and more securely. SFTP would be a FAR better way to go, and easier to script for, since it is not only encrypted, but can be passwordless via key exchanged. But you still haven't shared any details, told us your goals, etc. We are happy to try to help you, but ignoring what everyone says, not answering questions, and editing posts (repeatedly in this case, re: post #1), makes it impossible for anyone to help you.
i was not rude to ask you such question. my script was not copied from some where else and it was done my me. if you wish to reply then its good or else no need it seems.
I do not think we can get upset with this user: he has no idea how to ask the questions properly or provide the information we would need to provide an answer that would help him.
Pointing him to the articles about the tags and how to ask an intelligent question MIGHT help.
Preeti: I recommend:
1. that you research the tools here for posting better questions.
2. that you consider the advice given that 'expect' tools may not be the correct tools for what you want to accomplish. One recommendation was rsync in a bash script, but other tools could also be used.
3. that after some time to research and consider, you come back here and post an update with information clearly posted that might help us to help you.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.