SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    SitePoint Wizard Crowe's Avatar
    Join Date
    Nov 2001
    Location
    Huntsville
    Posts
    1,117
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    [SOLVED] FTP with php to old IBM Mainframe

    I have a project where I need to ftp a text file and run some commands. It's working fine under Windows (batch file) and I need to do it via php, (or shell, I'm not picky).

    Here is the Batch file and supporting files.

    batch file
    ftp -i -n -s:c:\~ftp\COMMANDS.txt XXX.XXX.XXX.XXXX
    (XXX is the IP address)

    COMMANDS.txt
    user ***** *******
    quote site recfm=fb lrecl=1500 blksize=27000 primary=5000 secondary=500
    put c:\~ftp\FTPDATA.txt 'FTPDATA2.TXT'
    quote site filetype=jes
    put c:\~ftp\more.txt
    quit
    (user/pass replaced with *****

    Can I do something like this with php? I know you can send user/pass, I know you can send the file (put) .. what about this "quote" business. I've never seen this in FTP before. That's the part I'm confused about.

    solution The solution was pretty simple. First, my host ended up not having ftp_connect with php (long story!) So I had to use a shell script. The "quote site" business is an FTP command, I'm not sure what it does as it's ftp server specific and these are commands for an old IBM mainframe. Here is my shell script though, and it worked like a champ.

    #!/bin/sh
    HOST='XXX.XXX.XXX.XXX'
    USER='USER'
    PASSWD='PASS'
    FILEA='data.txt'
    FILEB='morestuff.txt'

    ftp -n $HOST <<END_SCRIPT
    quote USER $USER
    quote PASS $PASSWD

    quote site recfm=fb lrecl=1500 blksize=27000 primary=5000 secondary=500
    put $FILEA uploaded.txt
    quote site filetype=jes
    put $FILEB more.txt
    quit
    END_SCRIPT
    exit 0
    Last edited by Crowe; Oct 11, 2004 at 15:11.
    Chrispian H. Burks
    Nothing To Say


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
  •