Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Help with a quick script.

  • 18-08-2002 4:34pm
    #1
    Registered Users, Registered Users 2 Posts: 158 ✭✭


    Ok, it's been a while, and I'm getting extremely lazy... but

    Here's the deal.

    I need to write a script which remotely accesses one machine from another and launch a said process on the remote box.

    For example, telnet/ssh to a unix server and start an X process.

    Any help much appreciated.

    P.S. It might be noted that I don't have a homedir on the remote machine, instead I simply have a login.


Comments

  • Closed Accounts Posts: 6,601 ✭✭✭Kali


    could do worse than use the Net::Telnet module for Perl...

    use Net::Telnet;
    $telnet = Net::Telnet->new
    (
    Timeout=>90,
    Prompt =>'%',
    Host => 'remotehost.com'
    );

    $telnet->login('username','password');
    $telnet->cmd("cd directory");
    $telnet->cmd("remotecommand");
    $telnet->close;

    and add that as a cron job if you want it done on a daily or whatever basis.

    disclaimer: theres nearly always a much easier way then the ways I come up with.


  • Registered Users, Registered Users 2 Posts: 1,038 ✭✭✭rob1891


    I think using expect would be the bog standard way of doing this. man expect and read up on it :P But if you've got perl ...


  • Registered Users, Registered Users 2 Posts: 171 ✭✭Wookie


    Use remote execution.

    Once you have set up server A on server B, server A can execute scripts on server B.

    Once setup it might be a little easier to use than the perl option.


  • Registered Users, Registered Users 2 Posts: 2,013 ✭✭✭lynchie


    If you have ssh on both machines, then simply type
    ssh user@machineB '/bin/sh /home/fred/scripts/run.sh'. This will just log in and execute the command and then exit the shell.


  • Registered Users, Registered Users 2 Posts: 1,862 ✭✭✭flamegrill


    Originally posted by lynchie
    If you have ssh on both machines, then simply type
    ssh user@machineB '/bin/sh /home/fred/scripts/run.sh'. This will just log in and execute the command and then exit the shell.

    The use of keys with ssh would allow you to do this from cron without the need to input a password.


  • Advertisement
Advertisement