Sign in to follow this  
Followers 0
jpoteet

Remote Client / Server Iniwrite problems......

10 posts in this topic

Hey guys.....

I have been browsing the forums here for a few days now looking for some solutions to my dilema. What I am trying to do is create a client / server environment where an .ini file sits on the server and collects data from the clients every 30 seconds. Using AutoIt Smith's Remote Server setup I am able to do most of this but there are a few problems I am having. One of the main problems is that I am trying to Iniwrite the following from the client to the server (doube quotes not supported):

IniWrite('C:\Program Files\blah\blah.ini', @ComputerName, 'Company Name', 'Test Company')

IniWrite('C:\Program Files\blah\blah.ini', @ComputerName, 'Address', '3344 Test St')

IniWrite('C:\Program Files\blah\blah.ini', @ComputerName, 'City,State,Zip', 'Testerton, VA 44333')

IniWrite('C:\Program Files\blah\blah.ini', @ComputerName, 'Run Script', '')

IniWrite('C:\Program Files\blah\blah.ini', @ComputerName, 'Remote', '0')

But when the client sends the info, the @ComputerName is always the server name (so only one section in the .ini no matter how many clients check in) and I need it to create a new section for each client PC that checks in.

Also is there a way that I can have the client look up their @ComputerName section in the .ini on the server to see if any flags have been set as far as the 'Remote' and 'Run Script' sections? I am planning on creating a trigger that if 'Remote', 1 then start a reverse VNC connection on the client. Any help is appreciated

Thanks,

JP

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Also is there a way that I can have the client look up their @ComputerName section in the .ini on the server to see if any flags have been set as far as the 'Remote' and 'Run Script' sections? I am planning on creating a trigger that if 'Remote', 1 then start a reverse VNC connection on the client. Any help is appreciated

Thanks,

JP

Several ways to approach this. One would be to place as part of installation a method to at runtime determine the value of @computername on the remote machine. The @ macros , as you have discovered , are going to return the value for the environment on which they run. So when you need the ones on the 'other' pc , you wiill need to force the other pc to provide it.

edit:typo

Edited by flyingboz

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Share this post


Link to post
Share on other sites

Ok I have tried to force the @ComputerName before sending it over to the remote server but I cannot get it to work. When I try this, I get is the variable name stamped in the .ini file on the server:

$ComputerName = @ComputerName

IniWrite('C:\Program Files\blah\blah.ini', '$ComputerName', 'Company Name', 'Test Company')

IniWrite('C:\Program Files\blah\blah.ini', '$ComputerName', 'Address', '3344 Test St')

IniWrite('C:\Program Files\blah\blah.ini', '$ComputerName', 'City,State,Zip', 'Testerton, VA 44333')

IniWrite('C:\Program Files\blah\blah.ini', '$ComputerName', 'Run Script', '')

IniWrite('C:\Program Files\blah\blah.ini', '$ComputerName', 'Remote', '0')

Problem is that the .ini on the server just has [$ComputerName] for the section header...when I need it to be the actual name of the sending PC. Is there any way to do this?

Thanks,

JP

Share this post


Link to post
Share on other sites

Ok I have tried to force the @ComputerName before sending it over to the remote server but I cannot get it to work. When I try this, I get is the variable name stamped in the .ini file on the server:

$ComputerName = @ComputerName

IniWrite('C:\Program Files\blah\blah.ini', '$ComputerName', 'Company Name', 'Test Company')

IniWrite('C:\Program Files\blah\blah.ini', '$ComputerName', 'Address', '3344 Test St')

IniWrite('C:\Program Files\blah\blah.ini', '$ComputerName', 'City,State,Zip', 'Testerton, VA 44333')

IniWrite('C:\Program Files\blah\blah.ini', '$ComputerName', 'Run Script', '')

IniWrite('C:\Program Files\blah\blah.ini', '$ComputerName', 'Remote', '0')

Problem is that the .ini on the server just has [$ComputerName] for the section header...when I need it to be the actual name of the sending PC. Is there any way to do this?

Thanks,

JP

Replace '$ComputerName' with $ComputerName ;)

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

When I try it that way I get an error stating Variable Undeclared....I think this is because I am sending the IniWrite command over to a remote server and the $ComputerName is not defined over there. What I need to do..but cannot figure out..is how to get the PC Name defined and inserted into my IniWrite statement before I send it over to the server.

Thanks,

JP

Share this post


Link to post
Share on other sites

When I try it that way I get an error stating Variable Undeclared....I think this is because I am sending the IniWrite command over to a remote server and the $ComputerName is not defined over there. What I need to do..but cannot figure out..is how to get the PC Name defined and inserted into my IniWrite statement before I send it over to the server.

Thanks,

JP

Doesn't sounds right ... the variable is defined in the first line ..

Show the script you are trying now ...

;)


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

When I try it that way I get an error stating Variable Undeclared....I think this is because I am sending the IniWrite command over to a remote server and the $ComputerName is not defined over there. What I need to do..but cannot figure out..is how to get the PC Name defined and inserted into my IniWrite statement before I send it over to the server.

Thanks,

JP

How is your executeable being run. Is the client running it from the server or is the server running the executable and trying to pull the data from the client remotely?


Be open minded but not gullible.A hammer sees everything as a nail ... so don't be A tool ... be many tools.

Share this post


Link to post
Share on other sites

So I am running two modules one based on TCPRecv and the other TCPSend. On the TCPRecv side I am using the following snippet:

Func AutoItExecute($Cmd)

RunWait(@AutoItExe & ' /AutoIt3ExecuteLine "' & $Cmd & '"')

EndFunc

This way, I can send commands to the server using the TCPSend interface. The command I am sending over looks like this right now:

$input1 = "IniWrite('C:\Program Files\blah\blah.ini', @ComputerName, 'Company Name', 'Test Company')"

$input2 = "IniWrite('C:\Program Files\blah\blah.ini', @ComputerName, 'Address', '3344 Test St')"

$input3 = "IniWrite('C:\Program Files\blah\blah.ini', @ComputerName, 'City,State,Zip', 'Testerton, VA 44333')"

$input4 = "IniWrite('C:\Program Files\blah\blah.ini', @ComputerName, 'Run Script', '')"

$input5 = "IniWrite('C:\Program Files\blah\blah.ini', @ComputerName, 'Remote', '0')"

$ret1 = TCPSend($socket,($input1))

sleep(100)

$ret2 = TCPSend($socket,($input2))

sleep(100)

$ret3 = TCPSend($socket,($input3))

sleep(100)

$ret4 = TCPSend($socket,($input4))

sleep(100)

$ret5 = TCPSend($socket,($input5))

sleep(100)

$recv = TCPRecv($socket, 512 )

$err = @error

This works fine but the @ComputerName when sent over, just keeps using the server name instead of the sending PC Name. That is why I tried the $ComputerName variable...and had no luck. So ultimately the problem I am having right now is how to get the @CompuerName inserted into the above command before sending it over to the server.......hope this makes sense.

Thanks,

JP

Share this post


Link to post
Share on other sites

something like this?

$input1 = "IniWrite('C:\Program Files\blah\blah.ini', " & @ComputerName & ", 'Company Name', 'Test Company')"

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Very nice....that seemed to have done the trick. Thank you very much for your help. I basically had to add '"& @ComputerName &"' and it works like a charm. Now I am guessing that if I want to send back information only to that client I would have to use the same sort of parsing.......

Thanks,

JP

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0