Checking for - Protocols

This is a discussion on Checking for - Protocols ; Hi All, I am getting files from a unix server to my machine running win2k using modem dial out. My script is working fine except one small thing. When I change the directory to where the files are supposed to ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Checking for

  1. Checking for

    Hi All,

    I am getting files from a unix server to my machine running win2k
    using modem dial out. My script is working fine except one small
    thing. When I change the directory to where the files are supposed to
    be, i want to check if the directory exists. If it does not then I
    want to exit.
    1. The "If Directory" command checks for the existence of the
    directory on the
    local machine not on the remote server. So that did not work.
    2. I also tried "remote query" method to get the pwd, but it shows as
    being
    unimplemented.
    3. "If fail" command also did not help.

    I tried a few more things but nothing seems to be working. Below is
    part of my script. After I do cd I want to check.

    If any body has any ideas, please help.

    Regards,
    Shruti.

    ************************************************** **********************
    output cd /mydirectory
    ;remote cd /mydirectory
    xif fail {
    set exit status 7
    fopen /write \%c \m(logfile)
    if fail exit
    fwrite /line \%c \%d
    if fail exit
    fclose \%c
    if fail exit
    clear device
    exit
    }

    output kermit\13 ; initialize kermit on host

    output send *.txt\13 ; get files
    receive
    ************************************************** *************************

  2. Re: Checking for


    "Shruti" wrote
    > i want to check if the directory exists. If it does not then I
    > want to exit.

    ************************************************** *****

    you don't mention anything about versions, this quick test
    script was tested on 2.1.3 of k95, connecting to some 8.0
    unix build. If fail works just fine.

    my script:
    ***************************************
    rdir /home
    if fail stop 1 no home
    rcd /home

    rdir /home/xxx
    if fail stop 2 no xxx
    rcd /home/xxx
    *******************************************
    My Results::: ( note the no xxx line at the bottom as the if fail returns
    true.)
    [C:\Documents and Settings\boz\] K-95> take c:/bat/rpwd.ksc
    Press the X or E key to cancel.
    drwx------ 4096 2004-08-31 09:07:19 /home/apeasy_wpa
    drwx------ 4096 2004-01-19 09:41:26 /home/boz
    drw------- 4096 2004-08-04 08:01:33 /home/data
    -rw------- 12 2004-08-14 11:42:13 /home/diskspace
    drwx------ 4096 2004-08-31 08:11:17 /home/nemclab
    drwx------ 4096 2004-04-23 08:58:55 /home/newark
    drwx------ 4096 2004-08-31 09:08:15 /home/nh_wpa
    drwx------ 4096 2003-03-31 12:34:53 /home/nhmrc
    drwx------ 4096 2004-08-31 09:09:34 /home/stp
    drwx------ 4096 2004-08-14 11:41:51 /home/test
    /home
    Press the X or E key to cancel.

    ?No files match
    no xxx
    ************************************************** **************




  3. Re: Checking for

    On 2004-08-31, Shruti wrote:
    : I am getting files from a unix server to my machine running win2k
    : using modem dial out. My script is working fine except one small
    : thing. When I change the directory to where the files are supposed to
    : be, i want to check if the directory exists. If it does not then I
    : want to exit.
    :
    : 1. The "If Directory" command checks for the existence of the
    : directory on the local machine not on the remote server. So that
    : did not work.
    :
    Correct, IF DIRECTORY applies to the local file system. Thus one would
    not expect it to work for remote files.

    : 2. I also tried "remote query" method to get the pwd, but it shows as
    : being unimplemented.
    :
    The QUERY feature is implemented in C-Kermit 6.0 and later. See below.

    : 3. "If fail" command also did not help.
    :
    It depends how you use it.

    : I tried a few more things but nothing seems to be working. Below is
    : part of my script. After I do cd I want to check.
    :
    If you have the name of an existing remote file and you try to CD to it,
    this will fail if the file is not a directory, or if you lack permission
    to CD to it, or it does not exist. Thus success is conclusive, but
    failure is not.

    Here is how you could use the QUERY feature to do what you want. Suppose
    "somefile" is the name of a file in the server's current directory. Then:

    remote query kermit directories(somefile)

    This will set the local variable \v(query) to 1 if "somefile" is a directory
    or to 0 if it is not a directory.

    remote query kermit directories(somefile)
    if \v(query) {
    (This section is executed if somefile is a directory)
    } else {
    (This section is executed if somefile is NOT a directory)
    }

    However, in testing this, I find that Kermit's built-in \fdirectories()
    function has a problem when given the name of a single directory (as opposed
    to a wildcard). This suggests the following workaround:

    remote query kermit directories(somefil[e])

    in which "somefile[e]" is a wildcard that matches only "somefile". I'll
    fix this bug next time around.

    - Frank

+ Reply to Thread