Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2001
    Posts
    892

    FTP shell script

    I need to mput a few hundred files from on of my servers to another, and I dont have the desire to sit there till it is done.

    I have a very basic knowledge of C php and perl and with that I was able to figure out a shell script that *almost* works for me. It works with the put command, but I cand figure out how to get it to work with the mput command

    Code:
    #!/bin/sh
    HOST='ftp.host.net'
    USER='yourid'
    PASSWD='yourpw'
    FILE='file.txt'
    
    ftp -n $HOST <<END_SCRIPT
    quote USER $USER
    quote PASS $PASSWD
    put $FILE
    quit
    END_SCRIPT
    exit 0
    Thanks for any help.

    BTW: while I'm asking this I'll ask another similar question too:

    The scenario: I have several images that I need to create thumbs for. I have downloaded and compiled the latest version of NetPBM. This will do the job for me.

    The problem: If I have 200 images i need thumbs for, I dont want to have to sit here typing in the command for each and every one.

    Here's the basics
    Assume the image is called "test.jpg", size of it is 1024x768. I
    want
    a thumnail of 100x100 at max, but leave the aspect ratio.

    # jpegtopnm test.jpg > test.pnm

    This extract the JPEG to the (non-lossy) PNM format

    # pnmscale -xysize 100 100 test.pnm > test_thumb.pnm

    -xysize specifies a bounding box. pnmscale scales the input image to
    the
    largest size that fits within the box, while preserving its aspect
    ratio.

    # pnmtojpeg --quality 75 test_thumb.pnm > test_thumb.jpg

    Converts the pnm to a jpeg, using the jpeg lossy quality of 75%.
    So what I need is some kind of script I can run that will do that for me. I specify the directory with the images it, and the word (say tn_) preceeding the thumb.

    Thanks again

  2. #2
    I am no script writer, but if I had a lot of files I wanted to move I would tar them up, move the one file and untar it....for example

    Original server

    tar -zcvf /var/www/html/backup.tgz /dirname/*

    New server
    wget http://yourwebservername.com/backup.tgz
    tar -zxvf backup.tgz



    I hope this helps you.
    *AlphaOmegaHosting.Com* - Hosting since 1998
    Managed Dedicated Servers and VPS
    Hosted Exchange 2010 Email Service

  3. #3
    Join Date
    Jul 2001
    Posts
    892
    I would like to do that, but on the second server I only have FTP access, so I wouldn't be able to untar the files

  4. #4
    Join Date
    Mar 2001
    Location
    California
    Posts
    332
    You should be able to do:

    Code:
    #!/bin/bash
    ftp -n your.host.com <<EOT
    user username passwd
    bin
    prompt
    mput *.jpg
    bye
    EOT

Posting Permissions

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