More bash help.
Sorry to keep bugging you guys about this stuff. I now have a backup script that works for everything except one small part. This backup script can rsync and create a tarball to push out to a mount point with zero issues, but when i try to push the tarball via ftp, it craps out on me. I can run the command manually with no issues so it is not the command. I must be missing something in the order of the script that I just can not see. an extra group of eye might just see it right off the bat.
Code:
#!/bin/bash |
below is the -xv output
the extra return in the lftp function was just added in hopes of breaking the cycle it creates: Code:
[rx30@rx30 ~]$ back.sh -f -x Code:
[rx30@rx30 ~]$ lftp -e 'set ftp:passive-mode on && cd rayb && put /tmp/rx-2012- |
the lftp command and the lftp function have the same name.
|
You named the function as the lftp command, so that every time you call lftp inside the function it calls itself recursively in an endless loop. Rename the function and the trick is done.
|
You should change your thread's title,giving more information in it.So others can help you.
|
thanks, i also found an other error. i was using the variable username in two different locations with two different =<stuff> changed the 2nd one from username => USER, i will also replace the name of the lftp function. ty
|
those 2 fixes did the trick. many thanks a.. making as solved.
|
Another way to avoid recursion is to use the command built-in.
Code:
foo() { In addition: 1) QUOTE ALL OF YOUR VARIABLE SUBSTITUTIONS. You should never leave the quotes off a parameter expansion unless you explicitly want the resulting string to be word-split by the shell (globbing patterns are also expanded). This is a vitally important concept in scripting, so train yourself to do it correctly now. You can learn about the exceptions later. http://mywiki.wooledge.org/Arguments http://mywiki.wooledge.org/WordSplitting http://mywiki.wooledge.org/Quotes 2) It's recommended to use ((..)) for numerical tests, and [[..]] for string tests and other complex expressions. Don't use the old [..] test unless you specifically need POSIX-style portability. http://mywiki.wooledge.org/ArithmeticExpression http://mywiki.wooledge.org/BashFAQ/031 http://wiki.bash-hackers.org/commands/classictest http://wiki.bash-hackers.org/syntax/...nal_expression 3) Clean, consistent formatting makes code readable and more easily debuggable. Indent all your sub-commands, and separate logical sections with whitespace. Add comments anywhere the code isn't completely obvious (and remember, what seems obvious to you now will not be a year or so down the line). Many people also think that it's more readable to place the "do/then" keywords on the same line as the "for/while/until/if" keywords, as it more clearly separates the outside block from the inside block. Code:
for var in fee fai foo fum ; do Finally, this is just my opinion, but using the full ${variable} pattern everywhere does nothing but make the code look more cluttered and harder to read. I suggest leaving the brackets off when you don't need them. 4) You have a large number of lines like this: Code:
MAXBACKSIZE=`df -hk | grep ${MOUNTDIR} | awk -F" " '{print $2}'` Second, Useless Use Of Grep. Awk can do all of the pattern matching itself. Just import the bash variable value into an awk variable. Third, since the same command is repeated so often, set up a function for it. Code:
getsize() { |
Thank you David the H. I will read over that, but here are some adjustments I have made to the script. It is now functioning as expected.
Code:
#!/bin/bash |
All times are GMT -5. The time now is 01:58 AM. |