Ninjakreborn Posted May 17, 2007 Author Share Posted May 17, 2007 Not sure where to add the "shebang" but I did this #! /usr/local/bin/php5 at the top of php before the opening tags, and inside php trying to echo it (both). Now I went into command line and tried running it again, and same message. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/page/2/#findComment-255694 Share on other sites More sharing options...
Ninjakreborn Posted May 17, 2007 Author Share Posted May 17, 2007 Ok, here is a log of what I "ran" through command line. after I had the shebang at the top u43118491:~/#######/wiki/maintenance > php -f createAndPromote.php #! /usr/bin/.php5Sorry! This version of MediaWiki requires PHP 5; you are running 4.4.4. If you are sure you already have PHP 5 installed, it may be installed in a different path from PHP 4. Check with your system administrator. u43118491:~/#######/wiki/maintenance > php -f createAndPromote.php Sorry! This version of MediaWiki requires PHP 5; you are running 4.4.4. If you are sure you already have PHP 5 installed, it may be installed in a different path from PHP 4. Check with your system administrator. u43118491:~/#######/wiki/maintenance > chmod +x createAndModify.php chmod: getting attributes of `createAndModify.php': No such file or directory u43118491:~/#######/wiki/maintenance > chmod +x createAndPromote.php u43118491:~/#######/wiki/maintenance > ./createAndPromote.php X-Powered-By: PHP/5.2.1 Content-type: text/html Please provide a username and password for the new account. u43118491:~/#######/wiki/maintenance > those are the commands/information I ran through command line recently. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/page/2/#findComment-255700 Share on other sites More sharing options...
Nameless12 Posted May 17, 2007 Share Posted May 17, 2007 chmod +x phptest should of been chmod +x php5test so i hope you did not copy and paste.  +x makes it executable, in linu x >> ./ << will execute a file, example ./filename. The file has to be executable before it can be executed though. The #! shebang is a unix thing, you can use it in perl, python and other languages.  #!PATH/GOES/HERE/TO/AN/EXE  #!/usr/bin/python #!/usr/bin/php #!/usr/bin/perl  or you can just do php filename.php, if you do this the file wont need to be executable but its best practice to do it with #!/usr/bin/php  #! has to be the first thing in a file. I have not tested it with spaces before it as that would be stupid but I am 100% sure it has to be at the very start of the file (no spaces or new lines)  When you type "php" in the command prompt it opens /usr/bin/php if you want to use it with the php5 exe you need to be specific  /usr/local/bin/php5/ <-- remember this is the correct path you should be using   Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/page/2/#findComment-255707 Share on other sites More sharing options...
Ninjakreborn Posted May 17, 2007 Author Share Posted May 17, 2007 WAIT... I understand now. When I execute a file, I don't really need php -f file.ext I can actually specific 2 parameters. The first is what to use to run the file, the second is the file name, or path to file name. So below, I put down the location of the php5 module. Then space Then the filename, and it ran. This time it gave me a different error. u43118491:~/####/wiki/maintenance > /usr/local/bin/php5 . /createAndPromote.php X-Powered-By: PHP/5.2.1 Content-type: text/html Please provide a username and password for the new account. u43118491:~/####/wiki/maintenance > businessman So a google (troubleshooting) method is always. use which to test what versions of php there are on the server and where. Then I can use that, to run the file through that in all situations.  Now was that error related to something else still related to command line, or something to do with the script I am installing. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/page/2/#findComment-255713 Share on other sites More sharing options...
zq29 Posted May 17, 2007 Share Posted May 17, 2007 Another thing I was wondering, when I try to do something like man -f which "-f" being what I used to try to run the file in the first place, it doesn't work. It works with ls though, which was VERY informational, thanks again. That is because -f is a switch that is being passed to PHP, running "man -f" would attempt to run man with the -f switch. To find out what the -f does, you'd run "man php" Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/page/2/#findComment-255720 Share on other sites More sharing options...
Nameless12 Posted May 17, 2007 Share Posted May 17, 2007 I dont see an error, I see two headers followed by an empty line and a line of text. For all I know this is what your script is meant to display. Although I dont quite know why your version of php is showing the headers it shouldn't. But look at the number in the headers  X-Powered-By: PHP/5.2.1 <-- 5.2.1  It should work without -f as well.  Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/page/2/#findComment-255729 Share on other sites More sharing options...
Ninjakreborn Posted May 17, 2007 Author Share Posted May 17, 2007 Ah, man php But in essence I never have a reason to run the php command, since he showed me how to do it the other way as ./filename.ext so.. I don't really ever have a need for php, I was just using it because a friend showed me that to run a php file.  Yes, there is no error as far as that's concerned. However I do have another information request. I ran this inside the command line. u43118491:~/#####/wiki/maintenance > /usr/local/bin/php5 . /createAndPromote.php X-Powered-By: PHP/5.2.1 Content-type: text/html Since I am on a learning binge today I wanted to ask a few questions. 1. Is this the same thing when running python/perl files. I just specific the directory of the processor, then the filename like this. 2. I know this is a great method, and I am so thankful for it working. However is there an alternative. Like can I somehow pass that "directory" into the php/python/perl file itself. SO it'll tell "whatever" server it's using to run that directory. or do I ALWAYS have to specify taht directory. I was hoping if I could put that within the php file itself, it would automatically get picked up as being like that. IS this possible, or do I always need to do it this way. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/page/2/#findComment-255734 Share on other sites More sharing options...
Nameless12 Posted May 17, 2007 Share Posted May 17, 2007 1. yes  I think you are confused because you are coming from windows, unix does not use file extensions the same way windows does. What you think is a directory is an executable *.exe  There are only two correct ways to do it  php FILENAME or #!/path/to/php  however there is a little trick but i dont think it would work properly on your server due to the multiple php versions.  #!/usr/bin/env php <?php  echo 'hello world!'; ?>  #!/usr/bin/env python works for python as well and why I have not tested it with perl as I dont use that, I would bet my life that also works.  Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/page/2/#findComment-255743 Share on other sites More sharing options...
Ninjakreborn Posted May 17, 2007 Author Share Posted May 17, 2007 Ok, thanks for clearing that up. The other thing I was wondering is what thorpe referred to as a "shebang". Is there a way for me to pass that at the top of the php, python, or perl script so it is automatically ran as that. I tried putting. /usr/local/bin/php5 as an echod out command in php, but it's not doing anything but showing it to the screen. The problem is, that is what I am using to run the file. /usr/local/bin/php5 createAndModify.php that is exactly what I ran, and it worked. However in the end, I want to see if I can get the /usr/local/bin/php5 part to be in the script in the beginning so all I have to do from command line is createAndModify.php and it'll do the same thing. Basically the reason is. After I get the command line memorized some, then I am going to create a few "test" applications and try to have some of those command line files that run through the browser. I have seen some you can create command line file's, that automatically connect to SSH and run all necessary commands. I am also going to be create other files. Python, perl, php 3, php 4, and php 5. I don't want to have to specify them all as I type them, I wanted to put something at the top of the page, so in command line it can already tell what to run them as. I guess this is where that shebang would come in, how do I utilize that where it will work. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/page/2/#findComment-255744 Share on other sites More sharing options...
Ninjakreborn Posted May 17, 2007 Author Share Posted May 17, 2007 Wait, that's why I got it working the way I wanted. I have one more question then I can close this topic down (with a wealth of knowledge from it). #! /usr/local/bin/php5 I added that to the top outside of the php tags, at the very top. I tried it without it and then with it only #! path worked. It doesn't work without the #!. Why is that, so anytime I ever run a command inside the php, python, or perl file itself then I need to have the #! at the beginning. (Is that what tells command line to pick up what is after that as a "command". Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/page/2/#findComment-255746 Share on other sites More sharing options...
Nameless12 Posted May 17, 2007 Share Posted May 17, 2007 as echoed out command in php?? You dont do that, it goes prior to the php tags. #! is for the operating system not for php. There is a simple solution to your problem, use php5 instead of 3 and 4. You have to specify one way or another, in windows you would do it with a file extensions but linux is different. I actually think #! is a better solution to the problem then file extensions. If you dont want to use #! I suggest you learn C Â You posted as I was typing this so parts of my message will be irrelivent but that was the whole point of #!/path/to/file, each tile you execute a script it checks for #! if it s there it tries executing the current file with the path provided after #! Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/page/2/#findComment-255752 Share on other sites More sharing options...
Ninjakreborn Posted May 17, 2007 Author Share Posted May 17, 2007 Perfect, thanks for all the advice. It's greatly appreciated, thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/page/2/#findComment-255760 Share on other sites More sharing options...
Ninjakreborn Posted May 17, 2007 Author Share Posted May 17, 2007 One last question. chmod +x phptest I went ahead and tried another file, and it came up like it didn't work. I actually used ti "With" an extension because I don't know anything about not putting extensions. So for example it ends up being chmod +x file.ext (if were in the same directory currently as the file). I have like 3 quick questions about this. 1. Can a file not be run at all until it's chmodded. 2. Does this go for perl/python scripts as well. 3. If I was creating a script that would need to be used later on another server (an auto-install system that uses command line or something), then people will get frustrated if things require being changed to executable before use. So is there a way to make a file automatically start off as executable, or something. Or whatever this chmod command with +x does. Also is this something maybe I could put at the top of the file liek I did with the other. Like #! chmod +x same thing as with the other, except chmod it then do the other. Will that take care of everything automatically (with regards to setting file permissions, and where to find the processor.) I know the one about processor works, because I Tested it. I just want to find out if the one about executable will work, and if that is required for python/perl files. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/page/2/#findComment-255778 Share on other sites More sharing options...
Daniel0 Posted May 17, 2007 Share Posted May 17, 2007 Try this echo /usr/bin/env php to get the path of the binary file. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/page/2/#findComment-255897 Share on other sites More sharing options...
zq29 Posted May 17, 2007 Share Posted May 17, 2007 1. Can a file not be run at all until it's chmodded.It can not be executed unless it has execute permissions. 2. Does this go for perl/python scripts as well.If you want to execute them, yes. 3. If I was creating a script that would need to be used later on another server (an auto-install system that uses command line or something), then people will get frustrated if things require being changed to executable before use.I think file permissions are stored in the file system rather than built into the files themselves, so they would have to be made executable on a different system, although a single install script could change the permissions of many files at once. Anyone correct me on this if I'm wrong. So is there a way to make a file automatically start off as executable, or something.Not that I'm aware. Or whatever this chmod command with +x does. The +x sets the file to have execute permission Also is this something maybe I could put at the top of the file liek I did with the other. Like #! chmod +x same thing as with the other, except chmod it then do the other. Will that take care of everything automatically (with regards to setting file permissions, and where to find the processor.) I know the one about processor works, because I Tested it. I just want to find out if the one about executable will work, and if that is required for python/perl files. No that will not work, as you'd have a chicken/egg situation - How can a file set itself to be executable if it can't be executed in the first place... Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/page/2/#findComment-255902 Share on other sites More sharing options...
Daniel0 Posted May 17, 2007 Share Posted May 17, 2007 Try this echo /usr/bin/env php to get the path of the binary file. Hmm, I somehow failed to notice there were more pages. Just nevermind my above post... Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/page/2/#findComment-255964 Share on other sites More sharing options...
Ninjakreborn Posted May 18, 2007 Author Share Posted May 18, 2007 Hi, I am going to basically use this same post for all my questions (saves space).  I set down for a few hours tonight and started playing with some coldfusion. It really wasn't something I was interested in but it was VERY easy to pickup some of it. After that I started playing with perl. It's almost like php on steroids. I mean you can use the $ for variables. The greatest thing is the for, while, if, elseif and other like control structures have roughly the same usage. The hardest part of perl seemed to not be the part about programming with it, but the part about setting it up. I had multiple issues. After about 2 hours I finally got it showing up in command line. The ONLY way I could do that was specify the path to the module then the file name. I tried to enter a shebang at the top of the perl page, and nothing. Another issue I had is no matter what I did I couldn't get that to come up in the browser. One thing I am really, really amazed at about perl was it's power over strings. Things that take 20 minutes in php take 10 seconds in perl. (I still prefer php) but I can see why people used perl for so long. It was one of the escape string. Basically though. 1. Why didn't the shebang work at the top of the perl page. 2. How do I get perl to showup in the browser so I can play with it there. 3. What do I need to do to get access to a server that support c, c#, and java. Python I can get access to from any server by just installing mod_python (that's how I have access to perl). Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/page/2/#findComment-256252 Share on other sites More sharing options...
redbullmarky Posted May 18, 2007 Share Posted May 18, 2007 i cant answer your others, but is there a reason why you'd want an actual live host for all this stuff? much of what you're trying can be set up on your local computer easily enough, or even better if you've got an old spare computer kicking around that you could set up as a server just to try stuff out on. it'll save you a few quid in hosting fees, too considering you're just really using it to mess about on. Â Failing all that, get a VPS and you can install whatever you like on it. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/page/2/#findComment-256401 Share on other sites More sharing options...
Ninjakreborn Posted May 18, 2007 Author Share Posted May 18, 2007 Well yes I have a development environment. The issue is with mod_perl above I can't get that working in the browser. Python for example I can just download mod_python and install it into apache on my development server and I am ready to go. As for other languages, yes that is a good idea but I don't know where to start to get access to some of those other languages. I guess for ruby find something called mod_ruby. I don't much about there initial setup. Even for coldfusion I was able to get it isntalled on my development, but I am still looking into where to upload my cfm files so I can start doing development on them, and playing around with it some. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/page/2/#findComment-256404 Share on other sites More sharing options...
trq Posted May 19, 2007 Share Posted May 19, 2007 All these mod_* things are apache modules. Nothing to do with the command line stuff. I would just use your hosts FAQ or contact support to get these working, they should already be setup. Â Python, Perl and C come standard on any Linux box. The easiest way to get these running would be to install some Linux distro. C# is used to develop .NET so, its a windows thing, and you'll need the .NET framework and (if you want to do web stuff) IIS. Â Seriously though bussi. it sounds like your going back down the path of trying to learn to much. You really wont get any good at any of these languages unless you concentrate on it alone. Looking around for a new language is fine, but once you've decided you need to settle with it. Â Ive been learning Python for the last 10-12 months or so and it still doing my head in. You may have looked at it, but there is allot more detail to any language than you may first realize. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/page/2/#findComment-256762 Share on other sites More sharing options...
Nameless12 Posted May 19, 2007 Share Posted May 19, 2007 3. What do I need to do to get access to a server that support c, c#, and java. Python I can get access to from any server by just installing mod_python (that's how I have access to perl).  Java (JSP) requires Apache Tomcat. and Java when used for the web is JSP, not "Java" Any language compiled to binary can execute the binary file in Apaches CGI-BIN Any script with the shabang can be run from the CGI-BIN also. And yes there are some Apache mods out there as you have just found out There is an open source project called mono to get the .Net stuff running on different operating systems. I have never used it so I dont know much about it or if it would work with Apache or not.    Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/page/2/#findComment-256846 Share on other sites More sharing options...
Ninjakreborn Posted May 21, 2007 Author Share Posted May 21, 2007 Thanks for all the advice, really appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/51836-solved-2-versions-one-server/page/2/#findComment-258370 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.