patmcl has asked for the wisdom of the Perl Monks concerning the following question:

I have a windows workstation that I store large amounts of test data. Other users store data on the server and I run perl scripts on the data to convert the data (post data processing). I have to be remote logged onto the workstation to run my scripts to do the post data processing. I would like to allow other users (who don’t have remote log on access) to run the scripts from the shared link. The problem with running from a “shared” link is that it tries to run the post data processing perl script on the external users local machine. I started to set up a socket to the workstation that simple runs the post data processing script when accessed. Is the socket over kill? Is there an easier way to tell the script to run on the computer that it is stored and not the computer that it is running the script? The data is way too large to change the script to work across the network (moving folders etc.). If socket method is the way to go how do I run the socket (IO::Socket::INET) in the background? Thanks.

Replies are listed 'Best First'.
Re: Socket or not
by JavaFan (Canon) on Nov 24, 2010 at 15:21 UTC
    Sockets are not the way to go. (Well, sockets will be involved in whatever solution, but you shouldn't build the sockets yourself).

    The problem you have isn't technical. It's political. The remote users don't have login access. There's a reason why. Whatever solution you will end up, it has to follow those constraints.

    You need to talk to the people in charge of the machine, express your wishes, and work out how to solve that issue. That's way better than asking for a skript kiddie solution on Perlmonks.

Re: Socket or not
by BrowserUk (Patriarch) on Nov 24, 2010 at 15:29 UTC

    By far the simplest way to allow remote users to run processes on your server, would be to give them ids on the server.

    These IDs can be locked down tight so that they can only see whatever you chose to let them see; and run whatever you choose to let them run.

    If they are other windows users on the same LAN/WAN then you only need add their domain IDs to an appropriate group on your server and the job is pretty much done. After all, this is what multi-user OSs are all about. If you don't know how to go about setting up an appropriately locked-down group, consider talking to your local systems administrator.

    Alternatively, if the users are getting to your server via the internet; or from machines running other OSs, then perhaps setting up a simple webserver which authenticates the users, and then presents them with a menu of tasks they can run would be your best option.

    Please don't be offended, but when you use phrases like "how do I run the socket", it indicates a lack of knowledge on your behalf that means that you trying to replicate even a small part of existing OS or webserver functionality yourself, in Perl, really isn't a good idea.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Yes, I know nothing about Sockets. I created a simple socket from examples that I found. It works fine saying hello world. I don’t deal with internet programming, I deal with data, data retention, data manipulation, data collection etc.. The technicians that spend hours transferring the large data files from the secured/isolated remote testing network to the workstation know nothing about logging on remotely. Their managers wont let them spend the time logging on remotely (I gave them simple instruction), it is very political. They have read/write access to the shared link to where they put the data on the workstation. When they were done getting the data to the shared workstation I wanted to make a batch file or a perl script that they could simply double click to run the conversion. They know when the data is available and sometimes the data is needed to be converted asap. I do have scheduled times for data conversion but they sometimes need the data at strange time. Sorry to waist your time.
        Sorry to waist your time.

        You didn't waste my time. I was attempting to avoid wasting yours.

        Programming, setting up, and maintaining, all the code, logistics and required security that sit behind your desired: "I wanted to make a batch file or a perl script that they could simply double click to run the conversion. " is a very involved process that would require you to learn substantially more about programming that you currently know.

        And the main point is, what you want is actually quite easy to setup, quickly & securely, using the existing facilities of your OS. But programming it in Perl will require considerable effort.

        If you are considering doing it in Perl in order to bypass some political barriers, then you should really think twice 10 times before going ahead.

        Because, if by doing this, you are crossing some "political" boundaries, then it could very well end up being detrimental to your source of income and career. Especially if you get the hardest aspect of the task--security--wrong.

        If you really insist on going ahead, then the simplest mechanism would be to create two directories below the current shared directory--say \\yourWorkstation\sharedspace\IN & \\yourWorkstation\sharedspace\OUT--and then you run--once at the beginning of each day or week--a simply script that monitors the IN directory, when it sees a file appear there, it runs the conversion process and writes the results to the OUT directory.

        Now all your users have to do is upload the files to the IN directory, and then check the OUT directory to see when the converted files are ready.

        But even this is not entirely trivial as your program will need to to not only detect when the files appear in the IN directory, but also wait until their upload is complete before starting to process them.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Socket or not
by VinsWorldcom (Prior) on Nov 24, 2010 at 15:26 UTC

    If I understand your question, you basically would like to Telnet to the Windows box and run some scripts - which would execute on the remote Windows box. This is like the *nix paradigm

    Unfortunately, Windows doesn't work like that. There is a Telnet service for Windows - not sure if it's installed by default or only available on Windows Server flavors, but that would require each user to have login credentials (you say they don't have remote log on access).

    VNC or Windows equivalent - Terminal Services - is an option, but again, remote log on access is required for TS and VNC would require users knowing a shared password for direct remote console access.

    Finally, there is psexec.exe from SysInternals. This also requires remote credentials.

    The socket path you're going down seems reasonable, but without any authentication/authorization, couldn't anyone connect and force your scripts to run? That doesn't seem so secure.

    Do you have any code done yet? Can you post something so we could be more help?

Re: Socket or not
by PeterPeiGuo (Hermit) on Nov 24, 2010 at 15:18 UTC

    One alternative is to run your script periodically. You probably need to slightly adjust your script, so it knows whether there is any new data to be processed.

    On the other hand, it is a fine idea to use a socket to talk. the coding is minimum.

    Peter (Guo) Pei

Re: Socket or not
by locked_user sundialsvc4 (Abbot) on Nov 24, 2010 at 18:57 UTC

    Other possibilities would be ... Windows remote access ... setting up a web-server-type program ... using a shared file that someone on another computer can write into ... using named pipes with a little slave-program that’s always running, listening to it.

    Regardless of those “possibilities,” you can be almost 100% certain that what you are considering doing, has already been done before.   You shouldn’t even have to use Perl.   Do some “Googling” to look at the existing body of work that should be available.

    For example, Googling “Windows remote execution” talks about things like rexec, rsh, and even one article (on page one) titled, “DoIt:   Yet Another Remote-Execution Daemon for Windows.”   I have not examined any of these programs; nor do I intend to.

    The fastest way to do anything, is to find a way not to have to do it at all.   To reduce your problem into a problem that is already-solved.   To a program that has already been written (even if you pay for it).

Re: Socket or not
by Argel (Prior) on Nov 24, 2010 at 22:35 UTC
    JavaFan and BrowserUK are right (in 873470 and 873506 respectively) -- a technical solution to a political problem is fraught with peril, and as BrowserUK indicates could even cost you your job!

    If it's as political as you indicate then you need to extricate yourself from the situation!! This is something your management should be working out with their management. And if it is your management that says this has to be done then you need to ask what the ramifications of doing something like this are instead of diving into a technical solution. And then you need to make sure your management understands the repercussions and make sure you get that in writing or in an email (i.e. that your management understands what they are getting into).

    Good luck and be careful!

    Elda Taluta; Sarks Sark; Ark Arks

Re: Socket or not
by aquarium (Curate) on Nov 25, 2010 at 01:11 UTC
    you can also execute a script on the server via a CGI wrapper that you write. the CGI wrapper just needs to make sure that it's not run simultaneously on same datafile etc. but this sort of sanity code is fairly straight forward. if there are no concerns about users getting to other users input/output data...then i would setup a inbox folder share visible to users, and an outbox share folder. the data munging CGI script is run from a html form where you select input file and whatever other parameters (including email notification address) and execute the job. the submitted html form (and CGI script) gives back a reference number and closes the window when user presses ok. the script proper (not the CGI) emails result link. internally the data munging script makes a copy of the input file in a non-public working directory, and output folder filename is generated, so as not to clobber any previous output file.
    for more futureproof access to the share, it would be a dfs share instead of a server wins hostname.
    the hardest line to type correctly is: stty erase ^H
Re: Socket or not
by Anonymous Monk on Nov 24, 2010 at 17:43 UTC
    Set up a scheduled task for each Perl script. The task can run under your ID.

    Provide .bat files (on the shared link perhaps) which use the schtasks Windows command to run the tasks. Users can just double-click the bat files to run your scripts.

    If needed, you could have the bat files accept paramters and write them out to .ini files on the shared link which could then be read by the scripts. You'd have to consider problems such as two users running the same bat file at once, but it's doable.

Re: Socket or not
by FloydATC (Deacon) on Nov 28, 2010 at 07:29 UTC
    The problem here seems to be not the upload/download part but the triggering of some conversion process at odd hours. Why not solve this simply by programming a tiny service/daemon that polls the input directory every N seconds for new data and then simply converts it into the output directory and goes back to sleep for another cycle? The techs could upload a bunch of files and then create an agreed-upon file named "convert.txt" to trigger the conversion process.

    Problem solved, no security issues.

    I would even go as far as to hint towards Powershell if politics is an issue, many Windows admins are more comfortable with using that cra^H^H^Hlanguage because they (incorrectly ofcourse) believe the code is easier to read than Perl.

    -- Time flies when you don't know what you're doing