Jump to content

htakeuchi

Members
  • Posts

    7
  • Joined

  • Last visited

htakeuchi's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I wish I had a smarter comeback... but I think spending too much time to "Glorify" <-- Note sarcasm this hair pulling "PowerShell" thing... is no worth my last few strands of hair left over!!! Yet... I still need some light this way to try and understand why the hell am I not able to do this!!!
  2. Hello: I have been developing a web tool to perform basic maintenance to 100's of MacOS units, which at this point it works fantastic. Now I am faced with the task of integrating 350 units in windows. The need is to send commands through powershell. I have tried to use system(), exec(), shell_exec() and have not been successful. The drop that spilled the cup this morning was... I sent a "reboot -r -t 01" command to a windows server hoping that it would perform a PSSession to a different non critical server, but to my surprise... You guessed it... I rebooted a production Server ... I am new to Powershell so I am not as fluent on it... But I am sure that it does not matter if you use a MacOS or a Windows or a Unix PHP server... the commands should be sent the same way and not platform dependent... Correct? Or is it that PHP needs a Powershell module installed such as ssh2?? As an example... How can I send a command to a Windows Unit from a php command? Let's say: shell_exec('powershell"Invoke-Command -ComputerName WindowsUnit1 -ScriptBlock { Get-Service dhcp } -Credential $Credentials"'); I have been getting the server to hang when trying to send this through a Windows based PHP server. I have added the "< NUL 2>&1" option at the end to get some feedback as well. On a MacOS based PHP server, the $credentials variable is unset, so.. in order for me to set the credentials, how can I do so? I hope someone here has faced this before and can shed some light my way. Thanks Hiroshi T
  3. Hello... I would like to ask for your expert opinion. I have created a small web form that will send some information via ssh2_exec() to a number of units on the filed through my WAN. I created a Web form, where I request the name of the units to be sent this information to separated by a comma, and this information then is setup as the array() in the php. But I am guessing that the _GET or the _POST is adding some character I cannot see to the names which causes the array to fail wen I perform the foreach()... Here is the small section of code I am using... ---------------------------------- <?php $nodes = $_POST['nodes']; $script = $_POST['script']; $hosts = array($nodes); foreach ($hosts as $host) { $hostname = $host; $url = 'ltf'.$host.'.domain.com'; $con =@ssh2_connect($url, 22); echo $nodes; if(!($con)){ echo 'Unable to to execute connection to Remote Unit<br>'; exit(1); } if (!@ssh2_auth_password($con, 'admin' , 'password')){ echo 'Failed to Authenticate to Remote Unit!'; exit(1); } elseif (!(ssh2_exec($con, '$script'))){ echo 'Command was not executed correctly<br>'; } echo "Connection to ".$host." was successful!<br>"; }; ?> Thank you so much in advance! HT
  4. Thank you very much! AyKay47, thank you very much for your reply, you are correct. Although, for some strange reason and very "Stupid" on my part, What I needed was to record on the CSV is the name of the oldest file being displayed (in this case $files[0]), prior to my posting here, I truly believe I requested that on the fwrite() command, but something must have not been written correctly. Last night I managed to get what I needed by simply adding the $files[0] on the data2append section, which in exchange, writes the file name on the CSV. I am very grateful for your assistance and for taking time to assist me. Here is how the Code looks right now and does what I wanted. Thanks again, Hiroshi T --- <?php $files = glob( './images/*.*' ); array_multisort( array_map( 'filectime', $files ), SORT_NUMERIC, SORT_ASC, $files ); echo '<html xmlns="http://www.w3.org/1999/xhtml"> <head> <link href="styles.css" rel="stylesheet" type="text/css" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Test Site</title> </head> <body> <div id="container"> <div id="formcontainer"> <form method="POST"> People Count: <input type="text" name="pcount"><br> <input type="submit" value="Submit"> </div> <!-- End of form Container--> <div id="imgcontainer"> <div id="imgframe"> <iframe src="'.$files[0].'" width="775" height="580" scrolling="no" frameborder="0"> </div> <!-- End of Image frame --> </div> <!-- End of Image Container --> </div> <!-- End of Container ID --> </body> </html>'; $imageDB = "imageDB.csv"; $DateStamp = date("m-d-Y"); $TimeStamp = date("H:i.s"); $openDB = fopen($imageDB, 'a') or die("Cannot update Database!"); $Data2appnd = "$files[0],$count,$DateStamp,$TimeStamp.\n"; fwrite($openDB,$Data2appnd); fclose($opendDB); ?>
  5. Thank you for both answers... The goal is to have a directory that is being populated by an FTP service, where images are being deposited, with this small php code, the goal is to open each image starting from the oldest inside the directory, once this is shown, using a form, the individual verifying the image, will set a comment via the form _GET or _POST. Once this is submitted, the image is moved to a different directory, (This part has not been written yet) The part where I was asking for help, needs to record the opened file's name and the comment form the form in a csv file, which also records date and time stamps. I believe "Barand's" option would be the best... I will get right to it and try both options and will report back... I sincerely appreciate your expertise. Kind regards Hiroshi T
  6. Hello: I would like to request an opinion so maybe I can find the reason which I am not being able to see for the following. I am using an array that will organize the content of a directory in the oldest to newest order, once it is ordered, display it's content. So far, so good, where I find my self stumped is when I want to send the array result to a csv file for record keeping. I am getting the word "Array" instead of the file name,... What am I doing wrong? I hope someone can assist me in understanding what am I doing wrong. Thanks... Hiroshi T <?php $files = glob( './images/*.*' ); array_multisort( array_map( 'filectime', $files ), SORT_NUMERIC, SORT_ASC, $files ); echo '<html xmlns="http://www.w3.org/1999/xhtml"> <head> <link href="styles.css" rel="stylesheet" type="text/css" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Test Site</title> </head> <body> <div id="container"> <div id="formcontainer"> <form method="POST"> Picture Count: <input type="text" name="pcount"><br> <input type="submit" value="Submit"> </div> <!-- End of form Container--> <div id="imgcontainer"> <div id="imgframe"> <iframe src="'.$files[0].'" width="775" height="580" scrolling="no" frameborder="0"> </div> <!-- End of Image frame --> </div> <!-- End of Image Container --> </div> <!-- End of Container ID --> </body> </html>'; //$count = _POST["pcount"]; $imageDB = "imageDB.csv"; $DateStamp = date("m-d-Y"); $TimeStamp = date("H:i.s"); $openDB = fopen($imageDB, 'a') or die("Cannot update Database!"); $Data2appnd = "$files,$count,$DateStamp,$TimeStamp.\n"; fwrite($openDB,$Data2appnd); fclose($opendDB); ?>
  7. Hello: This is my first posting, I am fairly new to PHP and Javascript, so please be nice! I have a question regarding a "Home Made" CMS for just a couple sections of the HTML on a site. I have managed to obtain the HTML by calling it with "Include" I use a couple forms which will gather the data to use for the change, then obtain the id of the DIV to change, all the changes happen by using some JQuery/Javascript, but since it is made by Javascript, all happens "Client side"... I am stuck here... and would like to see if there is a way to make PHP take the new changes into variables that will then replace the content in the HTML file? Let's say... I have a Fuel Pump and I have published the fuel price on my site... I have to change the price every day... so I want a small "admin portal" where I can type the fuel price and with it submit the changes to the site... here is the sample code I have been playing with so far... <html> <head> <link href="test.css" rel="stylesheet" type="text/css"> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"> </script> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Testing Changes</title> </head> <body> This section has the area you can modify:<br> <br> <form method="GET"> Change Fisrt line with: <input type="text" name="gasPrice1"><br> Change Second line with: <input type="text" name="gasPrice2"><br> <input type="submit" value="Change!"> </body> </html> <?php echo "<br><br>"; include 'index.html'; echo "<br><br>"; $var1 = $_GET["gasPrice1"]; $var2 = $_GET["gasPrice2"]; echo "<br>"; echo $var1 . " This is the echo from the first Variable"; echo "<br>"; echo $var2 . " This is the echo from the second Variable"; ?> <script> var gPrice1 = "<?php echo $var1; ?>"; $(document).ready(function(){ $("#text1").text(gPrice1); }); var gPrice2 = "<?php echo $var2; ?>"; $(document).ready(function(){ $("#text2").text(gPrice2); }); var txt=document.getElementById("text1").innerHTML; document.write(txt); </script>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.