1. Local Area Network Access
- Posted by MichaelB Jan 22, 2010
- 1558 views
This forum is great so much good information, but I haven't found what I need and am probably looking in the wrong place. I am writing software to perform backups across my local network at home. When the backup is done the software will shutdown all the computers. I am sure that there is already software out there to do this, but this is as much as a learning project as it is a functional one.
QUESTION How do I access my network. I have windows xp sp3 and I know that when going through My Computer I can go to My Network Places and see the computer name ex:
abcdef. However when I try to use the win32lib commands to open the computer and a folder nothing happens ex:
abcdefg\My Documents. I am using the standard walk_dir command, but I've also tried using the demo file from win32lib to do this. My win32lib version is 0.70.4a. How can I go about accessing the other computer to write and read files in Euphoria.
Thanks for your help, MichaelB
2. Re: Local Area Network Access
- Posted by irv Jan 22, 2010
- 1529 views
Windows? You have, I believe, several options. See this page: http://support.microsoft.com/kb/308582 I haven't done this in so long, I no longer remember which I used.
3. Re: Local Area Network Access
- Posted by ChrisB (moderator) Jan 22, 2010
- 1459 views
Hi
Yes, you must use the net use x:
computer name\share name, where x: is the drive letter you want to assign to the shared resource.
You can do this from a command line (in a batch file), or with system (I think)
Then you can access the drive as if it wer local
Then use net use x: /delete to disconnect the drive, and go on to the next one
I use this in a batch file to monitor for ghostscript files on a linux server, so it connects at startup.
Chris
4. Re: Local Area Network Access
- Posted by m_sabal Jan 23, 2010
- 1509 views
You can also use UNC pathing, assuming the computer the program is running on has permission to access the computers and folders it needs. UNC pathing looks like this:
Computer1\Share1\Folder1\File.txt
Computer2\Share1\Folder33\File.txt
As far as being able to remotely shutdown a computer, and you have permission to do so, you can this from a shell execute:
shutdown -s -f -m
Computer1
5. Re: Local Area Network Access
- Posted by MichaelB Jan 23, 2010
- 1405 views
Thank you for the information. I don't understand the UNC pathing though. How could I use that in say software form using one of the commands in win32lib, or is that even possible. On the UNC I am thinking that computer 1 would be the name of the computer as I would see in network places i.e.
abcdefg and share 1 would be a shared folder such as
abcdefg\My Documents. Is this correct? If so it wouldn't work in the walk_dir command. However I think that I can use the Net Use command by doing a shell_execute and assigning my computers. I will play around with this and see what happens. I really appreciate the great advice you've led me in the right direction.
6. Re: Local Area Network Access
- Posted by alanjohnoxley Jan 24, 2010
- 1480 views
Have a look at "PSTOOLS" from www.sysinternals.com
This has lots of GUI and command line functions for remote windows machines, over the network.
I've used these with Euphoria to find and delete illegal files from remote machines.
The "PSLIST" for example, may be a simple replacement for walk_dir, depending on what you want.
HTH!
Regards, Alan
7. Re: Local Area Network Access
- Posted by alanjohnoxley Jan 24, 2010
- 1408 views
The "PSLIST" for example, may be a simple replacement for walk_dir, depending on what you want.
Sorry, I meant "movefile", pslist will list processes, not files.
8. Re: Local Area Network Access
- Posted by MichaelB Jan 24, 2010
- 1389 views
Thanks for the tip I'll look into that. I've been reading the MSDN developer site and I think that the WNet functions in the windows api may be what I need. I just need to determine how to access those functions using euphoria and how to write a .ew file to get to those functions. However, I will definitely look at the PLIST first since it might already do what I am hoping for. As I said in my first post, this is as much about learning if not more. And being able to learn how to access the windows api will help me to become a better programmer. I've been diving into the win32lib code to see how its done, it is just such a huge file it will take some time. Am I correct in assuming that win32lib is working its magic :) by interfacing with the different dll's that it includes? Again thanks for the support.
9. Re: Local Area Network Access
- Posted by jacques_desch Jan 25, 2010
- 1366 views
Thanks for the tip I'll look into that. I've been reading the MSDN developer site and I think that the WNet functions in the windows api may be what I need. I just need to determine how to access those functions using euphoria and how to write a .ew file to get to those functions. However, I will definitely look at the PLIST first since it might already do what I am hoping for. As I said in my first post, this is as much about learning if not more. And being able to learn how to access the windows api will help me to become a better programmer. I've been diving into the win32lib code to see how its done, it is just such a huge file it will take some time. Am I correct in assuming that win32lib is working its magic :) by interfacing with the different dll's that it includes? Again thanks for the support.
UNC =\\machine_name\share Say the remmote machine host name is computer1 and that "computer1" share a folder under "docs" name UNC =\\computer1\docs from euphoria you should be able to open a file using: integer fh fh = open("\\computer1\docs\document1","r")
Jacques
10. Re: Local Area Network Access
- Posted by MichaelB Jan 26, 2010
- 1299 views
Just wanted to thank everyone for their help. I still can't get the code to work. What I want the software to do is to detect all computers on the network and then backup specific files as set within a config file to the network hard drive. I want the software to be automatic so that it can occur during the night when I am not working on the computer. I have been researching the MSDN website and have found some possible alternatives. I just need to try and implement them then cross my fingers. In win32lib I noticed that their is not a routine similar to walk_dir that it is win32api based and from what I've read, dos doesn't support network computers, or at least that is the impression that I get. I am still working on it though, thanks to all.
11. Re: Local Area Network Access
- Posted by m_sabal Jan 27, 2010
- 1264 views
There's no reason why you can't use walk_dir in a win32xxx based program. Just because you're using the Windows API for the UI, it doesn't stop you from using the built-in Euphoria functions for everything else. If you are running Windows, you don't have the option of using DOS. The cmd window and the associated shell commands (like dir, chdir, etc.) are all part of Windows, and they just work. Be careful not to over-engineer the solution. If you are on a network, and you want to access files on a remote computer, as long as you know the computer name and as long as the computer is on and on the network, you can treat those remote files exactly the same as you would treat any local file or directory. It's built into Windows; you don't need any special API for it. If you don't know the computer name, I have to wonder how you can know the names and locations of the files you want to copy.
Here is a simple example of creating a file on a remote computer. All other file-related operations work the exact same way:
fn = open("\\\\pa-files2\\data\\pa_data\\_stats\\"&userdata[2],"w") if fn < 3 then abort(1) end if
Userdata is a sequence populated with information about the local computer. Field 2 happens to be the serial number. Later on I do this:
dlist = dir("C:\\Program Files") if sequence(dlist) and length(dlist)>0 then puts(fn,"Contents of Program files directory:\n") for ctr = 1 to length(dlist) do puts(fn," "&dlist[ctr][1]&"\n") end for end if
How I have a hidden directory on a remote server that contains a file for each workstation with the contents of the program files directory, along with some other helpful information. I use it to diagnose any potentially harmful or out-of-date software installed on my network against company policy. This runs on Windows natively, no special API or DOS required.