Professional Web Applications Themes

Weird Script behavior - Linux / Unix Administration

Hi All, We have a backup script that runs, backups up some files, and then FTP's them to a remote server. The script runs from beginning to end. No errors. However, when it hits the FTP step, it simply does not FTP the files. However, if I run the script manually, it FTP's the files just fine. I run the script as root, which it also does from the cron. Anyone have any ideas? Here is a snippit of the FTP step: ftp -nv 192.168.1.100 <<_HERE_ user user password cd $ftp_path ascii prompt mdel * $( for file in *.sql ...

  1. #1

    Default Weird Script behavior


    Hi All,

    We have a backup script that runs, backups up some files, and then
    FTP's them to a remote server.

    The script runs from beginning to end. No errors. However, when it
    hits the FTP step, it simply does not FTP the files.

    However, if I run the script manually, it FTP's the files just fine.

    I run the script as root, which it also does from the cron. Anyone
    have any ideas?

    Here is a snippit of the FTP step:

    ftp -nv 192.168.1.100 <<_HERE_
    user user password
    cd $ftp_path
    ascii
    prompt
    mdel *
    $( for file in *.sql ; do
    print "put $file"
    done )
    bin
    $( for file in *.zip ; do
    print "put $file"
    done )
    bye
    _HERE_


    Thanks.

    amerar@iwc.net Guest

  2. #2

    Default Re: Weird Script behavior

    In article <googlegroups.com>,
    net wrote: 

    Usually, scripts that work from command line but not cron fail due to some
    difference in the user environment. Since you don't mention which shell you
    use, which shell the script uses or which OS you are using, you aren't going to
    get a lot of help...

    Cron usually executes commands with /bin/sh, so if your script has no shebang
    line, it will execute with /bin/sh, which may not be the same behavior from the
    command line. In addition, cron's PATH variable is typically much smaller than
    your interactive shell's.

    Kevin
    --
    Unix Guy Consulting, LLC
    Unix and Linux Automation, Shell, Perl and CGI scripting
    http://www.unix-guy.com
    Kevin Guest

  3. #3

    Default Re: Weird Script behavior

    Kevin Collins wrote: 

    > [/ref]
    .... [/ref]
    .... 
    >
    > Usually, scripts that work from command line but not cron fail due to some
    > difference in the user environment.[/ref]

    And most often because of starting directories. Cron starts
    jobs in your home dirctory, but that doesn't seem to be the
    issue this time.
     

    And so I trimmed the snippet down to the bits that will only
    work in KSH. In Bourne that would use backticks but I
    don't know if you can do a whole loop inside a backtick
    expression in Bourne the way you can in Korn. Might
    need to shuffle those parts up and stitch together the input
    not use a here-doc.

    Doug Guest

  4. #4

    Default Re: Weird Script behavior


    Sorry, I should have mentioned it.....this is being done in KSH.......

    amerar@iwc.net Guest

  5. #5

    Default Re: Weird Script behavior

    On 2006-01-14, net wrote: 

    What is? Please read: <http://cfaj.freeshell.org/google>.


    --
    Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
    Shell Scripting Recipes: | My code in this post, if any,
    A Problem-Solution Approach | is released under the
    2005, Apress | GNU General Public Licence
    Chris Guest

  6. #6

    Default Re: Weird Script behavior

    net wrote: 

    I wrote a very similar script, and FTPs things just fine, whether
    I run it through cron or interactively.

    I would try replacing "ftp" with "cat", run the script from cron,
    and see if you are getting the ftp commands you expect that you
    should be getting.

    By the way, you should be able to do "mput *.sql" and "mput *.zip"
    instead of those for loops you're doing.

    - Logan
    Logan Guest

  7. #7

    Default Re: Weird Script behavior

    In article <googlegroups.com>,
    net wrote:
     

    Could there be different versions of "ftp" on your system? Since cron
    jobs don't run .profile, they don't have the same $PATH, so it might be
    running a different version than when you run the script manually.
     

    --
    Barry Margolin, mit.edu
    Arlington, MA
    *** PLEASE post questions in newsgroups, not directly to me ***
    *** PLEASE don't copy me on replies, I'll read them in the group ***
    Barry Guest

Similar Threads

  1. Weird web service behavior
    By Homam in forum ASP.NET Web Services
    Replies: 0
    Last Post: June 30th, 09:29 PM
  2. CollectionEditor weird behavior
    By A.J. van der Burg in forum ASP.NET Building Controls
    Replies: 1
    Last Post: January 28th, 02:03 PM
  3. HERE'S a new and weird behavior!
    By Joel_C_Harris@adobeforums.com in forum Adobe Illustrator Macintosh
    Replies: 11
    Last Post: May 16th, 07:01 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139