Running a putty cmd line through php script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mkx
    Confirmed User
    • Nov 2003
    • 4001

    #1

    Running a putty cmd line through php script

    I have to login to root with putty daily to type in "sendmail -q" to process the mail queue. Is there a way for me to do this through a php script instead so I can have someone else do this whom I don't want to give root access? Maybe even a cron job? I use cpanel
  • codingwelt
    AdultCoding.com PHP Freak
    • Sep 2014
    • 58

    #2
    It's possible, yes. But you shouldn't let a script log in as root user. You could allow a non-/less-privileged user to execute the command using php, so there wouldn't be that much impact if someone got access to the login details stored in the php file.
    (see PHP commands like "exec", "system", "passthru", ... for executing system commands.)

    But, why aren't you creating a cronjob for root user that executes sendmail -q for you? There's no need to do this in PHP if not absolutely necessary.
    AdultCoding.com Webdevelopment - info [smth] adultcoding [smthelse] com - Skype: AdultCoding
    Individual PHP development following the latest standards in the web industry.
    Get in touch for a custom offer, now!

    Comment

    • edgeprod
      Permanently Gone
      • Mar 2004
      • 10019

      #3
      Originally posted by codingwelt
      But, why aren't you creating a cronjob for root user that executes sendmail -q for you? There's no need to do this in PHP if not absolutely necessary.
      You just asked a user who called the shell "putty" (an app) why they aren't using a cronjob. Do you think they know what any of that means?

      Comment

      • mkx
        Confirmed User
        • Nov 2003
        • 4001

        #4
        what do I put as the command for the cron job in cpanel, I can do that

        Comment

        • Babaganoosh
          ♥♥♥ Likes Hugs ♥♥♥
          • Nov 2001
          • 15841

          #5
          Better question is why is your queue filling up?
          I like pie.

          Comment

          • mkx
            Confirmed User
            • Nov 2003
            • 4001

            #6
            I have 50 emails going out at the same time during a certain part of the day

            Comment

            • freecartoonporn
              Confirmed User
              • Jan 2012
              • 7683

              #7
              if you just want to fire a command then you dont need a script , just add a cronjob of the same.

              become root
              crontab -e
              //time interval //insert your crontab command
              save n exit.

              somthig like this.
              SSD Cloud Server, VPS Server, Simple Cloud Hosting | DigitalOcean

              Comment

              • fuzebox
                making it rain
                • Oct 2003
                • 22351

                #8
                Originally posted by edgeprod
                You just asked a user who called the shell "putty" (an app) why they aren't using a cronjob. Do you think they know what any of that means?

                Comment

                • codingwelt
                  AdultCoding.com PHP Freak
                  • Sep 2014
                  • 58

                  #9
                  Originally posted by edgeprod
                  You just asked a user who called the shell "putty" (an app) why they aren't using a cronjob. Do you think they know what any of that means?
                  Nope, but maybe it will help someone who has the same problem, anytime soon...
                  AdultCoding.com Webdevelopment - info [smth] adultcoding [smthelse] com - Skype: AdultCoding
                  Individual PHP development following the latest standards in the web industry.
                  Get in touch for a custom offer, now!

                  Comment

                  • edgeprod
                    Permanently Gone
                    • Mar 2004
                    • 10019

                    #10
                    Originally posted by codingwelt
                    Nope, but maybe it will help someone who has the same problem, anytime soon...
                    Maybe. I'd say that someone with that level of technical sophistication doesn't need help.

                    Comment

                    Working...