Clarity

Expand all | Collapse all

How to access a shared network path from GEL ?

  • 1.  How to access a shared network path from GEL ?

    Posted Oct 12, 2010 07:08 AM
    Hi All,

    We are trying to read a CSV file through a GEL script and trying to make updates in Clarity based on CSV data. Currently, we have to place the file from the Shared Network to the App Server and then make the GEL Script access the file by giving the file location as C:\<some_folder>.

    Is it possible for GEL to read the file from the shared location directly by giving a network path? I have tried giving the Full network path as the folder location but failed to read the file via GEL.

    I am trying to use the below code to read the file -


    <gel:formatDate format="MMddyy" stringVar="FileDate"/>


    <u:available file="${Defaultdirectory}${file.separator}${Sourcefile}${FileDate}.csv">


    <core:set value="${Defaultdirectory}${file.separator}${Sourcefile}${FileDate}.csv" var="Commaseparatedfile"/>


    <gel:log level="INFO">The Selected File is ${Commaseparatedfile}</gel:log>

    </u:available>

    Here ${Defaultdirectory} is the drive location and ${Sourcefile} is the name of the file. The ${FileDate} is just to identify the latest file.

    Thanks for the help.
    ~D


  • 2.  RE: How to access a shared network path from GEL ?

    Posted Oct 12, 2010 07:08 AM
    Yes this should "just work".

    The key thing though is that the network path must be visible to the o/s user that is running the BG service that the GEL script is running through.

    i.e. its not good YOU being able to see the "H drive" if the "Clarity bg service" does not have that drive mapped (or does not have valid file access permissions on the drive).

    --

    I had a similar Q a few months ago; 10046064

    unfortunately the "code snippets" that were posted to my thread are currently missing in the new boards though.


  • 3.  RE: How to access a shared network path from GEL ?

    Posted Oct 12, 2010 07:08 AM
    Thanks Dave.

    I have been trying to setup a drive which everyone can access, so that we can call it from GEL. However, as rightly said, the OS User needs to see the folder.

    I have requested the user who posted the code in your thread to re-post them, if he can. Would wait for response now.. :sad

    ~D


  • 4.  RE: How to access a shared network path from GEL ?

    Posted Oct 12, 2010 07:08 AM
    ^ ok that "code snippet" was a way of getting a GEL script to run an o/s command - in my case to run a script that mounted a shared drive in the environment that the GEL was running.

    If you can administrate your network successfully yourself to give access to the shared drive from the GEL o/s user then you should just be able to get it to work without any extra GEL "code snippets". In my case I needed to "log on" to a drive to be able to read files from it.


  • 5.  RE: How to access a shared network path from GEL ?

    Posted Oct 12, 2010 07:08 AM
    Dave,

    If you still have the GEL Code for running a DOS command, please can you share at this post?

    I have tried various ways of mapping a network drive and accessing it via clarity but failed. If you can share the GEL Code, it would greatly help as then I can try to do all the operations from the code itself.

    Thanks
    ~Dev


  • 6.  RE: How to access a shared network path from GEL ?

    Posted Oct 12, 2010 07:08 AM
    ^ I can (and I will!), but it will be next week by the time I have access to it.


  • 7.  RE: How to access a shared network path from GEL ?

    Posted Oct 12, 2010 07:08 AM
    OK, something like this;

    <core:invokeStatic className="java.lang.Runtime" method="getRuntime" var="javaRuntime"/>
    
    <core:set value="GELTEST.bat" var="myArgs"/>
    
    <core:invoke method="exec" on="${javaRuntime}" var="execBAT">
        <core:arg type="java.lang.String" value="${myArgs}"/>
    </core:invoke>
    
    <core:invoke method="waitFor" on="${execBAT}" var="waitBAT"/>
    So the "GELTEST.bat" file is sitting on the BG server that is running the GEL (in the "%NIKU_HOME%\bin" directory I think, somewhere at the top of the path anyway) and that bit of GEL will run that file and wait until its finished....


  • 8.  RE: How to access a shared network path from GEL ?

    Posted Oct 12, 2010 07:08 AM
    Thanks for the code, Dave.

    However, I am still not able to make the GEL script access the CSV on network path. The batch file I am using runs a NET USE command with the user credentials to map a network drive. The GEL has to access the files on the shared path, for further processing.

    The BG OS user has correct permissions, the shared folder has given the appropriate permissions to it. I am just puzzled why the GEL Process should not work.

    Did you try to perform the same actions for your process? Any ideas why mine is not working?

    Thanks
    ~Dev


  • 9.  RE: How to access a shared network path from GEL ?

    Posted Oct 12, 2010 07:08 AM
    Yes thats exactly what I was trying to do, just establish the shared drive mapping using the DOS script run from the GEL environment.

    --

    This worked OK for me in my DEV environment, but as soon as I put it into PROD, it didn't work quite the same; I did not have the time (or inclination) to debug my PROD domain problems, so I quickly re-engineered it;

    Now the DOS script (still called from the GEL), establishes the network share, then just copies the file to somewhere local on my BG server that the GEL could always access. And at the end of the GEL I run another DOS script to copy back to the network share a simple log file.

    Not very elegant but it works. (And I still don't know why the original attempt just establishing the network share did not work - but I no longer care!)


  • 10.  RE: How to access a shared network path from GEL ?
    Best Answer

    Posted Oct 12, 2010 07:08 AM
    Thanks Dave.

    We figured the issue was with the User Credentials on the network. We are now trying to make the BG Services log on with a different account. Hopefully, the process should work after this change.

    Just for everyone's benefit, putting some points below:

    1. If we need to make GEL access a BAT file on the BG Server (Windows Environment), we can use the code mentioned in Dave's post above. We have the option of putting the file on the BIN directory on Clarity_HOME or we can specify the whole path of the BAT file for var - myArgs. Example, in the code in above posts we can write -

    <core:set value="<some_drive>${file.separator}<some_folder>${file.separator}<your_file>.bat" var="myArgs"/>

    2. Check the Administration - Services - Niku Background Service - Properties - Log on. The user mentioned in this property window should have access to map drive, access network paths etc.

    Thanks
    ~Dev


  • 11.  RE: How to access a shared network path from GEL ?

    Posted Apr 23, 2011 07:14 PM
    Hi Dave,

    First Thanks for your contributions to this community. I was trying to invoke a bat file from a gel script and came across this post. I used the script you have provided above and when I run the GEL script, I do not see any evidence of my bat file being run. My bat file for now creates a directory for testing purposes.

    I am new to GEL and not sure where to start troubleshooting. I reviewed the BG log file and no errors pointing to this bat file. I am invoking the gel from a command prompt at this time.
    Both my below messages print indicating that the script has executed the invoke tags between them. Any help is greatly appreciated.

    My GELTEST.bat is present in Clarity_Home\bin. Not sure what is going wrong.

    My Script is as below:
    <gel:script xmlns:j='jelly:core'
    xmlns:gel='jelly:com.niku.union.gel.GELTagLibrary'>
    <j:forEach indexVar='i' begin='1' end='1'>
    <gel:out>Hello World rocks $!</gel:out>
    </j:forEach>

    <j:invokeStatic className="java.lang.Runtime" method="getRuntime" var="javaRuntime"/>
    <j:set value="GELTEST.bat" var="myArgs"/>
    <j:invoke method="exec" on="${javaRuntime}" var="execBAT">
    <j:arg type="java.lang.String" value="${myArgs}"/>
    </j:invoke>
    <j:invoke method="waitFor" on="${execBAT}" var="waitBAT"/>

    <j:forEach indexVar='i' begin='1' end='1'>
    <gel:out>After Invoke ${i}!</gel:out>
    </j:forEach>
    </gel:script>






    Dave wrote:

    Yes thats exactly what I was trying to do, just establish the shared drive mapping using the DOS script run from the GEL environment.

    --

    This worked OK for me in my DEV environment, but as soon as I put it into PROD, it didn't work quite the same; I did not have the time (or inclination) to debug my PROD domain problems, so I quickly re-engineered it;

    Now the DOS script (still called from the GEL), establishes the network share, then just copies the file to somewhere local on my BG server that the GEL could always access. And at the end of the GEL I run another DOS script to copy back to the network share a simple log file.

    Not very elegant but it works. (And I still don't know why the original attempt just establishing the network share did not work - but I no longer care!)


  • 12.  RE: How to access a shared network path from GEL ?

    Posted Apr 24, 2011 08:30 AM

    Rimond wrote:

    I do not see any evidence of my bat file being run. My bat file for now creates a directory for testing purposes.
    My GUESS would be that it is BAT file related.

    First up; the location of your file; I think thats its only important that the BAT file is on your system PATH; when we are running a GEL script through the application then it is running "as" the user that owns the BG service, therefore it needs to be on the path for that user (which is where the Clarity_Home/bin dir becomes important).

    ...BUT when you are running it from the command line I guess it needs to be on YOUR user's PATH... so if you just type GELTEST.BAT does it work?

    Next up; if your BAT script is creating directories, is it possible (likely?) that the user you are running it as does not have the permissions to create the directory (or even is not referencing the directory correctly?). Personally I'd try to get my "test" BAT file to do something much simpler than creating directories (like just dumping some text to the screen!) whilst I debugged gettting it to run and then only move up to the complicated stuff when I was convinced my script was being run correctly (or indeed at all!). (Dumping text to screen will work ok when you are running the GEL from the command line, but when you are running it from the app it will not (since the BAT is being run by the BG service))

    --

    In all the cases where I'm trying to get a buch of "complicated" things to all work together, I start out small, I check the obvious stuff (like is my BAT file running) before I try to do the clever things (like O/S commands; creating directories, FTPing files etc)

    Dave wrote:

    Not very elegant but it works
    :grin:


  • 13.  RE: How to access a shared network path from GEL ?

    Posted Apr 25, 2011 02:30 PM
    Thanks Dave, I got it to work.

    As you indicated that path of my .bat file was correct, but my new directory(requested in my bat file) was not being created in the Clairy_Home\bin but under Clarity_Home. Looks like the BG server account runs the bat file under Clarity_Home directory.

    After this worked, I invoked a exe file on C:\program Files\ and it ran successfully.
    Appreciate your help.


  • 14.  Re: RE: How to access a shared network path from GEL ?

    Posted Jul 15, 2014 03:11 PM

    I know you may no longer care, but I enjoy seeing the myArgs variable still living!

     

    if you look at the application services under windows 

         start > run > services.msc

     

    most likey you will see everything running under the

         "Local System" account

     

    For distributed/shared instances, the clarity process should really be running as a user account.  In the old days you would have to modify this in windows everytime the application got redeployed.   Now I believe they give you options in the nsa/csa configuration.

     

    Microsoft restricts the ability of this account to do local network communications only.   So that is the most likely reason you couldn't get your network share to map.

     

    ---

    Thanks again for reposting the java.lang.Runtime code in its various forms.  It really helps me with the only 'NDA' thing I was ever worried about.  :-)