Posted on 2005-04-25
Last Modified: 2010-03-05
i have a cronjob that runs contains

$string .= "\nTesting\n";
#$string =~ s/\n/\\\n/g;
#$string =~ s/'/'"'"'/g;
system "ssh", "out1", "/u/rshah1/", "'$string'";

it does not works it does not login to out1 machine

however if i run manually from command prompt it works fine. i have set up sshkeygen

Question by:shahrahulb
    LVL 1

    Author Comment

    ssh is not working thru cronjob
    LVL 20

    Assisted Solution

    There are a variety of differences between the environment a process sees when it is run from the command line and the environment it sees if it is executed as a cron job.

    The first question I'd have to ask is whether the cron job is running on your behalf. The ssh keys are user-specific.
    LVL 16

    Accepted Solution

    I;d probably also code the entire path to the ssh command in your system(). As jmcg has explained, PATH is one environment variable which is not available when a script is run thru cron

    system "/absolute/path/to/ssh", "out1", "/u/rshah1/", "'$string'";
    LVL 2

    Expert Comment

    Make sure that your pl has the approriate attributes. chmod it to 755 or else the cronjob wont't have authority to execute it.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
    Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now