tcl – package require ftp List command with asterisk Win2016

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf tcl – package require ftp List command with asterisk Win2016

  • Creator
    Topic
  • #55717
    Peter Heggie
    Participant

    We just migrated our FTP site to Windows Server 2016. When using tcl package FTP, or just entering a command at the command line in an FTP session, using an asterisk on a list command to check for the existence of a directory returns nothing. Using a trailing asterisk on a DIR command inside a directory and checking on the existence of a file works correctly. It is only failing when you are trying to determine whether a certain directory exists, and the only items in the current directory are sub-directories. This used to work in the previous version of our FTP server, I think it was Windows Server 2008.

    Has anyone encountered this?

    Our tcl script is an archival process which runs daily, and creates a new sub-directory for each month – example name: archive_201805

    So it checks to see if the sub-directory is already there and if so, then skips the command to create a new sub-directory, otherwise it creates it. Again, this runs every day, so it only needs to create the sub-directory once.

    I guess I could modify the script to just issue the create directory command  and handle the error, but possibly this functionality could be more important in other situations.

    Peter Heggie

Viewing 4 reply threads
  • Author
    Replies
    • #86297
      Steve Williams
      Participant

      Peter,

         Microsoft has been pushing Powershell for over a decade now and just hates DOS and its simplistic legacy. I’ve ran into trouble with DOS commands on WinServ2012 this past year, so I’m not surprised at more issues in WS2016 and the DOS command line. In the past, I’ve also had issues with AIX v6 to v7, and moving from AIX to Linux. My point here is I’ve learned not to make system calls in my TCL and Perl scripts unless absolutely necessary.

      With that in mind, when writing TCL scripts, I do not use exec or system calls (like dir in Windows or ls -l in Unix) as this limits the platform the scripts can be used on.

      Since TCL provides native functions to handle most types of system calls. For example, file exists archive_201805 to see if your new directory already exists and file isdirectory archive_201805, just to be sure it’s a directory you can write into. You can also use glob for handling wildcards in other situations. This has made my TCL scripts more portable and reliable. I still make system calls for hcidbdump and hcicmd, etc.

      In short, I’m suggesting you nix the DOS calls and use TCL native functions for accessing/evaluating the file system. But, I suspect you already knew this. 😀

    • #86298
      Peter Heggie
      Participant

      Thank you – no, I did not know that. I have not written Windows scripts in a while but I do remember seeing the power of the utilities. But I recognize the better method of using agnostic routines and scripting languages like tcl.

      I’m kid of stuck here – Cloverleaf is running on AIX and this FTP server is on Windows. The FTP package that comes with Cloverleaf seems to behave differently when talking to this new version of the Windows FTP server – I’m sure its the FTP software.

      I think I will not execute an FTP List command, but just run the mkdir command and handle the error. Hopefully I will get the same command line output – code 257 is returned on both Windows and AIX for a successful mkdir command, and a 550 + “exist” is returned for a failure due to an existing directory. But I have to test this with tcl package FTP.

      Peter Heggie

    • #86299
      Steve Williams
      Participant

      The FTP package that comes with Cloverleaf is quite old and is expecting certain behavior in output from given FTP commands. So, I suspect you’re dead on correct that the WS2016 output to a ls -l has changed and

    • #86300
      Jim Kosloskey
      Participant

      Unless the target system’s FTP Server is configured to not allow Change of Directory for security reasons. Then you would fail and possibly not know programmatically why.

      Worth checking out I would think.

      email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

    • #86301
      Peter Heggie
      Participant

      I can still use the command line on the Cloverleaf AIX server to invoke the AIX FTP client and issue all the commands, including CD and Get.

      I can use the FTP package with TCL and issue the ::ftp::cd command and it works fine (by verifying with the ::ftp::pwd command).

      I have another more serious issue with this combination of the FTP package and the upgraded Microsoft FTP service which I will detail in a separate post.

      Peter Heggie

Viewing 4 reply threads
  • The forum ‘Cloverleaf’ is closed to new topics and replies.

Forum Statistics

Registered Users
5,117
Forums
28
Topics
9,292
Replies
34,432
Topic Tags
286
Empty Topic Tags
10