Results 1 to 5 of 5

Thread: Get environment variable path of server from local system

  1. #1
    Join Date
    Jun 2015
    Posts
    94
    Thanks
    20
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Get environment variable path of server from local system

    Hi Everyone,

    I'm working on a local system, and my one file is stored on a server.

    Let's say, On Server, we have set an environment variable (setx FILE //173.15.3.40/myUser/file.txt).
    That variable is used in a file(serverFile.xml) stored in server itself.

    serverFile.xml
    ----------------------------------------------
    <property index="0" name="File Name" value="%FILE%"/>
    ----------------------------------------------
    Now, I'm accessing this file(serverFile.xml) from a local server, and I can access it, but my local system don't know what is FILE means. I know about QByteArray qgetenv ( const char * varName ), which gives you path of that environment variable, but how I can do the same on Server from Local system using QT Programming?

    I'm using QNetworkRequest, QNetworkAccessManager to communicate with the server. (REST API)

    Simply how to find what is path set for FILE from our local system?

    Any concept or hacks will be appreciable.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Get environment variable path of server from local system

    Well, obviously your server side code will have to replace the variable.

    This isn't something you can do locally, the implementation of the REST API needs to be able to deal with such variables.

    Cheers,
    _

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,142
    Thanks
    235
    Thanked 661 Times in 651 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Get environment variable path of server from local system

    Sounds like the OP's scenario is that he reads the serverFile.xml file, retrieves the property element with the "FileName" attribute, reads its "value" attribute (which contains the literal string "%FILE%"), and is then stuck because he has no way to remotely determine the value of %FILE% on the server machine.

    It doesn't sound like there is any server-side program at all, it's just being accessed as a remote file system.

    But if the remote file system can set the value of an environment variable to point to a specific file, then why can't that path simply be written to the XML file instead?

    And as a comment, "FILE" seems like a particularly bad choice for an environment variable that forms a critical part of a processing system. "XYZ_APP_FILE" or something a bit more app-specific might be a better choice.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Get environment variable path of server from local system

    Quote Originally Posted by d_stranz View Post
    Sounds like the OP's scenario is that he reads the serverFile.xml file, retrieves the property element with the "FileName" attribute, reads its "value" attribute (which contains the literal string "%FILE%"), and is then stuck because he has no way to remotely determine the value of %FILE% on the server machine.
    Right, thus the client needs to pass on the path with the variable intact so that the server can interpret it.

    Quote Originally Posted by d_stranz View Post
    It doesn't sound like there is any server-side program at all, it's just being accessed as a remote file system.
    Well, the comment said server access happens through a REST API, so I assumed it would have some for of "get file" call.
    This call needs to support paths with environment variable for this to work properly.

    Cheers,
    _

  5. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,142
    Thanks
    235
    Thanked 661 Times in 651 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Get environment variable path of server from local system

    Well, the comment said server access happens through a REST API, so I assumed it would have some for of "get file" call.
    This call needs to support paths with environment variable for this to work properly.
    Ah, yes, missed that. So there must be some server-side code running, and that's where the environment variable needs to be resolved.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 2
    Last Post: 19th October 2017, 23:25
  2. Replies: 7
    Last Post: 31st May 2012, 21:52
  3. Qt Creator PATH Environment Variable
    By dohzer in forum Qt Tools
    Replies: 3
    Last Post: 4th December 2010, 06:50
  4. Replies: 8
    Last Post: 17th October 2009, 08:10
  5. System environment variable
    By fahlen in forum Qt Programming
    Replies: 4
    Last Post: 27th November 2007, 19:02

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.