FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


C++ for cronjobs?





Twisol
Can C++ programs (as .exe's) be used as server cronjobs? It would be great if so, since I'm a [novice] C++ programmer, and I don't want to have to take the time right now to learn Perl or Python or whatever else I would use.
TomS
nope. For that you need a server with shell access.
And the Frihost (and almost every other) server is running un a unix system. So your exe's won't run there.
MrBlueSky
Yes, it will work IF you compile your C++ programs for Linux.
Twisol
So Linux doesn't have a .exe extension? Huh.

What's the difference between compiling for Linux and compiling for Windows, and couldn't compiling for Linux be done from Windows? Or is there nothing like a switch for OS-specific compilation? (or whatever).

I'm just looking to do file/database manipulation using the C++ cronjobs, and it'll all be Standard C++ (no OS specific stuff), so can't such a program, compiled and run on Windows, run on Linux as well?
qebab
I very much doubt that. You would have to compile it for linux.
MrBlueSky
Twisol wrote:
So Linux doesn't have a .exe extension? Huh.

What's the difference between compiling for Linux and compiling for Windows, and couldn't compiling for Linux be done from Windows? Or is there nothing like a switch for OS-specific compilation? (or whatever).

I'm just looking to do file/database manipulation using the C++ cronjobs, and it'll all be Standard C++ (no OS specific stuff), so can't such a program, compiled and run on Windows, run on Linux as well?


Programs compiled for Windows can not be runned on other operating systems. They have different executable file-formats and different API's.

To compile your program for Linux you have several options:

1. Use a cross-compiler. Which is, basically, just a normal compiler with the switch for OS-specific compilation you mentioned. You can use it to compile Linux programs on Windows or the other way around.
2. Install Linux on a partition of your computer. This gives you a great opportinuty to experiment with a great OS!
3. If you don't want to install Linux you can use a LiveCD, a Linux Distro that you can just boot from cd-rom. For example Knoppix
4. You can compile your source on frihost by using a Perl or PHP oneliner, for example:

Code:

<?php

   passthru ('gcc yourfile.cpp');

?>


5. You can use PHP (or Perl) to emulate shell-access to Frihost and compile your program on Frihost. See: http://www.frihost.com/forums/vt-25644.html or install something likeWebshell. (Protect it with a password!)
Twisol
I'd go for option 4, but I doubt Frihost has gcc on it, and I wouldn't know how to put it on a Frihost page properly.

On that note, is there a Perl or Python interpreter on Frihost?

EDIT: My bad, I just noticed the Frihost home page notes Perl and Python capabilities...
MrBlueSky
They also have gcc Smile

You can use the php from my previous post. Put it in a file ending with .php and upload it to a subdirectory of public_html. Use the filename of your c-file instead of yourfile.cpp and make sure to upload your c-file(s) to the same directory where compile.php (for example) is located. Then request compile.php from your webbrowser.

You probably need to check the GCC manual a few times.
Twisol
Frihost has GCC... god, can Frihost get any better? Thanks for the code and instructions, you were a big help!
Nyizsa
Twisol wrote:
So Linux doesn't have a .exe extension? Huh.


Linux doesn't care about extensions. You can add an .exe extension to your executables if you want, but it won't matter.

Twisol wrote:
What's the difference between compiling for Linux and compiling for Windows, and couldn't compiling for Linux be done from Windows? Or is there nothing like a switch for OS-specific compilation? (or whatever).


You can compile the source under any OS you want, provided that it doesn't include platfrom-specific system calls. Normal programs should be fine.
Cron jobs are simply execution of commands at a given time. The commands can be of any supported language.
Twisol
Nyizsa wrote:
You can compile the source under any OS you want, provided that it doesn't include platfrom-specific system calls. Normal programs should be fine.


Aha, that's what I was asking about. So, I can just compile a program on my local computer and upload it to Frihost, set it as a cronjob, and it'll work fine? Awesome, thanks!
Nyizsa
Twisol wrote:
Nyizsa wrote:
You can compile the source under any OS you want, provided that it doesn't include platfrom-specific system calls. Normal programs should be fine.


Aha, that's what I was asking about. So, I can just compile a program on my local computer and upload it to Frihost, set it as a cronjob, and it'll work fine? Awesome, thanks!


Not really. Yes, you can compile it on any computer, but then it will run only under that operating system!
So, if you want to set something up as a cronjob, you need to compile it here on Frihost or on an other computer running Linux. If you were thinking about compilation under Windows and uploading the resulting .exe, it won't work.
darth_revan
Nyizsa wrote:
Twisol wrote:
So Linux doesn't have a .exe extension? Huh.


Linux doesn't care about extensions. You can add an .exe extension to your executables if you want, but it won't matter.

Yup, when you compile your file,
gcc file.c -o output.exe
this'll create a file called output.exe
./output.exe runs that file you just created.
Related topics
Command and Conquer
Funny C variable
What can I do with C-Panel?
HELP ME in C++
Languages in c++
C++ TUTORIAL : INTRODUCTION TO C++
I searching for a site
Image Processing in C++ by Shirish
C en C++
C# tutorials
C en C++
C#,Visual Basic.NET,Visual Studio.NET Videos
[Question] Visual Basic C++, PHP, mySQL language guides...
compiling and running cgi in C, not perl
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.