2

I have been searching for an answer to this for a couple of hours with no clear answer.

I normally write .php scripts which do helpful administrative tasks on my website. I upload them to an ftp folder, and run them from my browser when I need them.

Unlike what I a used to, I am trying to run a script (someone else wrote it) to and have been told that I cannot do so from the browser and I need to do it from the command line. Basically everything is set up, but I cannot push to go button and run the script.

Any ideas? I have php installed on my local computer and can run scripts locally from browser and command line, but I do not know how to do the same for the scripts on my website.

I don't know if this helps, but my server is apache and runs off php version 5.3.3

4
  • So, you are trying to run a command line PHP script from your browser? Try exec('php yourScript.php'); from another PHP file. Commented Jan 3, 2014 at 17:12
  • 1
    If your OS is unix/linux lookup cron jobs if you run on Windows lookup TaskScheduler these both can be used to launch a PHP script on a regular basis, be that every minute or every hours or ... so on. Commented Jan 3, 2014 at 17:18
  • why cant you run it from browser? are not you allowed to, or its not in the public_html directory? and what is your OS ? Commented Jan 3, 2014 at 17:32
  • If I put your two comments together, I can get some of these daily scripts to be run through task scheduler. This is great! Though I still won't be able to run the script in question here. I am in Windows. I think I am not allowed to. Commented Jan 3, 2014 at 18:16

2 Answers 2

1

When the black window open, it will ask you for your credentials:

  • Write your ssh credentials, if you have. If you dont, try with the ftp user and password.
  • If it doesn't work...get into your host control panel, and find out how to create an SFTP, or SSH user. If you can't find anything, contact support asking how to create that kind of user. When you have it

After you login, your are inside your server, and you can move around, as you would in linux. If you dont know the basics, find a good tutorial. Or just relay in:

  • ls : list the files and directories
  • pwd : know in what directory you are
  • cd DIRNAME : change to other directory inside de current one
  • cd .. : change to the parent directory

When you are in the directory where your script lives, just execute:

  • php yourscrip.php
Sign up to request clarification or add additional context in comments.

1 Comment

I looked used those linux commands, and was able to find and run the script from the SSH. Success! Thanks so much for everyone helping out. Much appreciated.
1

if its a php script

php path_to_script.php

else

/path/to/script

If its the second option you will need to chmod +x /path/to/script first

These should all be run from a ssh session (or any other way of accessing a command line on the machine running the website)

to ssh to a sever use putty if on windows. Your host will be able to give extra details on how to access

2 Comments

It sounds like the OP does not know how to SSH into his server.
Okay I have gotten in touch with my web host, done a 101 on SSH, and am connected to the server. I need to find the path to the script as it seems the root directory of the site FTP (which I am familiar with) is not the same as the web server. @user1281385

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.