i have looked for a week and tried a few things, but nothing seems to work so joined here.
I have a go daddy account and also a vps in germany. In my vps, i run a code script (we will call it codegen) when i run
./codegen
i get my question of how many codes do i want to make. With my answer on the screen, my codes are made and as the same time the codes are put in a file called /var/etc/codes.cfg to be read by my other script every 1 min.
great! But i want this file linked from a script i have on godaddy. i can run the script codegen ok on godaddy and of course can make a file called codes.cfg with the codes inside, but as this is not on my vps. its pointless as the codes cant be used for access as my program is on my vps and scans that code.cfg every min for new codes to allow. how can i link godaddy to my vps to run codegen?
i was guessing that codegen can be run from within another script.
so I added this to another script i have:
return shell_exec(__DIR__ . "/codegen $arg");
This works great on my VPS. 80% all ok, but as i stated. how can i change the above to run from ssh or login from go daddy to vps?
i followed about 8 ways from goggling and nothing works.
many thanks
BTW i`m very very very new to all coding, so maybe a step by step?
I guessed was something to do with ssh keys and making a key, tried that and no luck.
Has the script been copied to your VPS, or do you just have the file locally?
good evening
i have the file on both godaddy and also my vps
in my vps its in the root
on go daddy in the config file folder inside the software
Can you ssh into your VPS using a password?
yes i can and do so daily to run updates ect
i followed this guide
http://www.linuxproblem.org/art_9.html
and can log on to my vps from ssh on go daddy, all i need is how to run file please
as in what to add into the line to run file
ssh username@host bash /scriptname.sh
If you're running it from cron or something, you might need to do something like ssh -i /home/.ssh/id_rsa username@host bash /scriptname.sh
i did try that as this
ssh username@host bash /codegen
-bash: /usr/bin/ssh: Permission denied
it seems soon as i close ssh on godaddy (testing ) the so called link above as i quoted the guide, does work mate.
Well, if you can't use bash, can you use /bin/sh ?
the file its self i run is a ksh
but the code i gave you is from a "thank you page " after a payment from pay pal.
the code part is
// Redirect to custom page on purchase
Am_Di::getInstance()->hook->add(Am_Event::THANKS_PAGE, 'onThanksPage');
function onThanksPage(Am_Event $event){
/* @var $di Am_Di */
$di = Am_Di::getInstance();
/* @var $invoice Invoice */
$invoice = $event->getInvoice();
/* @var $controller ThanksController */
$controller = $event->getController();
$controller->redirectLocation('/compsetup');
}
// Exec C/N script
Am_Di::getInstance()->hook->add(Am_Event::USER_MENU, 'myAddMenuItem');
function myAddMenuItem(Am_Event $event)
{
$menu = $event->getMenu();
$menu->addPage(
array(
'id' => 'compsetup-id',
'controller' => 'compsetup',
'module' => 'default',
'label' => "Complete Setup",
'order' => 500
));
}
class CompsetupController extends Am_Controller // a Zend_Controller_Action successor
{
function indexAction()
{
$user = $this->getDi()->user; //currently authenticated customer or throws exception if no auth
$this->view->title = "Complete Setup";
$this->view->content = doScriptExec();
$this->view->display('layout.phtml');
}
}
function doScriptExec() {
// Get list of used products
$prodids = file_get_contents(__DIR__ . "/used_products.txt");
foreach (Am_Lite::getInstance()->getAccess() as $a) {
if ((strtotime($a['begin_date']) < time()) && (strtotime($a['expire_date']) > strtotime("today")) && (!strstr($prodids, "$a[access_id]\n"))) {
$access_id = $a['access_id'];
}
}
if (!$access_id) return "<p style=\"color: RED;\">You have already generated a code for a connection or have not bought a membership. If this you feel is an error, please email the site owner.</p>";
if (!$_REQUEST['corn']) {
return '<form method="post" action="#"><select name="corn"><option value="c">C</option><option value="n">N</option><option value="mg">MG</option></select><input type="submit" value="Setup" /></form>';
} else {
$arg = $_REQUEST['corn'];
$prodids = $prodids . "$access_id\n";
file_put_contents(__DIR__ . "/used_products.txt", $prodids);
return shell_exec(__DIR__ . "/codegen $arg"); }
}
as started this works 80-99% on my vps so is a working live script.
but i want to put the script on my godaddy account as closing my vps and moving
so i need to now how to change the bottom to run the script from there
loads of sites say ssh user@host and then the part for file
but cant seem to work
i think needs the ssh keys set up
i even tried
ssh root@host 'bash -s' < /codegen to get a sintext error
Well, if it's ksh, you'd use ksh, not bash.