Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1047015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:14:15+00:00 2026-05-16T16:14:15+00:00

I am attempting to create a php script that can connect thru ssh to

  • 0

I am attempting to create a php script that can connect thru ssh to my Qnap TS219 server and run a command on it.

My script so far connects fine to the server but when I run the command I get an error message and I can’t figure it out.

exec.sh

#!/bin/bash
cp /share/MD0_DATA/Qdownload/rapidshare/admin/script.txt /share/MD0_DATA/Qdownload/rapidshare/admin/script.sh
chmod 755 /share/MD0_DATA/Qdownload/rapidshare/admin/script.sh
nohup sh /share/MD0_DATA/Qdownload/rapidshare/admin/script.sh &
exit 0

script.sh

#!/bin/bash
/opt/bin/plowdown -o /share/MD0_DATA/Qdownload/rapidshare /share/MD0_DATA/Qdownload/rapidshare/admin/down.txt 2>/share/MD0_DATA/Qdownload/rapidshare/admin/output.txt

the command that I am currently running thru ssh after I submit the form:

echo $ssh->exec('sh /share/MD0_DATA/Qdownload/rapidshare/admin/exec.sh');

Right now generates the code below but only after I kill 2 bash processes (the page keeps loading indefinetly and the processor activity is at 100% if I don’t kill the 2 bash processes):

/share/MD0_DATA/.qpkg/Optware/share/plowshare/lib.sh: line 261: getopt: command not found start download (rapidshare): http://rapidshare.com/files/312885386/Free_Stuff-Your_Internet_eBay_Business_Free_Startup_Resources.rar /share/MD0_DATA/.qpkg/Optware/share/plowshare/lib.sh: line 261: getopt: command not found /share/MD0_DATA/.qpkg/Optware/share/plowshare/lib.sh: line 46: --insecure: command not found Error: failed inside rapidshare_download() 

This script will be used in my local network, no access from outside, so I am not worry about security, I know the code looks very basic, primitive but I have no experience with php, shell script, so if someone can make any sense on this and help me out will be greatly appreciated.

Edit1. I also tried the shell_exec command still no joy and if I run the script thru putty works beautifully.

Edit2. I think we are on to something.

I added the code you suggested and I got the following message.

sh: /share/MD0_DATA/.qpkg/Optware/share/plowshare: is a directory /usr/bin:/bin:/usr/sbin:/sbin 

I think at the moment the PATH is usr/bin:/bin:usr/sbin:/sbin and I think it should be /opt/bin /opt/sbin because there are the “executables”. Any ideeas?

Thanks,
Chris.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:14:16+00:00Added an answer on May 16, 2026 at 4:14 pm

    Run this

    echo $ssh->exec('pwd');
    

    Does it list your path correctly? If so then your problem is NOT PHP, if it doesn’t list or still gives an error then PHP is your problem and we can continue from there.

    From the error you’ve listed, my first guess would be that PATH isn’t set, so lib.sh can’t find what it’s looking for.

    Remember you’re logging in with a custom shell (PHP ssh), quite often things aren’t set as they should be, so your scripts might not find requirements like paths and variables.

    Edit:
    Since it’s giving /root, we at least know it’s going through, why not also set the PATH etc…

    echo $ssh->exec('PATH=$PATH;/share/MD0_DATA/.qpkg/Optware/share/plowshare; sh /share/MD0_DATA/Qdownload/rapidshare/admin/exec.sh');
    

    Remember you can also use this to see what is and isn’t being set.

    echo $ssh->exec('ECHO $PATH');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP script that creates large complex tables. I am attempting to
I'm attempting to create a php template that includes object oriented code. Here's a
I am attempting to create a UPnP method on an internal PHP server if
I need to create a PHP script that receives XML input via an HTTP
Have a script that I can copy and run in mysql shell just fine,
I'm attempting to create a table for monitoring purposes using the following script: $w3wppriv
I am attempting to create a report, utilizing a matrix, that only displays columns
I am attempting to create a simple tracker using php and google maps. Right
I am attempting to create an effect on my website that once you hover
I'm attempting to create a map that allows users to report a trailwork problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.