Batch Crossing Over
Moderator: DosItHelp
-
- Posts: 287
- Joined: 16 Mar 2011 19:17
- Location: scriptingpros.com
- Contact:
Re: Batch Crossing Over
I need to learn about this sleep business. I have been up for over 48hrs now, and am starting to see things.
Re: Batch Crossing Over
You understand this, I have been looking to freely move the cursor in dos for ages...
PLEAZZZZZZE
@orange_batch posted it in
http://www.dostips.com/forum/viewtopic.php?f=3&t=1868
PLEAZZZZZZE
@orange_batch posted it in
Code: Select all
void SetPos(int x, int y) {
static HANDLE hOut = GetStdHandle( STD_OUTPUT_HANDLE );
COORD pos = {x, y};
SetConsoleCursorPosition( hOut, pos );
}
http://www.dostips.com/forum/viewtopic.php?f=3&t=1868
-
- Posts: 287
- Joined: 16 Mar 2011 19:17
- Location: scriptingpros.com
- Contact:
Re: Batch Crossing Over
Why would you want to do this, what purpose does it serve?
Re: Batch Crossing Over
I don't wan't to add ansi.sys as device driver.
And even if I did I don't know if it would work.
The purpose, depends on the latency, if it is to slow, not much.
It does replace constructions like
And even if I did I don't know if it would work.
The purpose, depends on the latency, if it is to slow, not much.
It does replace constructions like
Code: Select all
cls &echo.he &@sleep 50
cls &echo. l &@sleep 50
cls &echo.hello &@sleep 50
loop
-
- Posts: 287
- Joined: 16 Mar 2011 19:17
- Location: scriptingpros.com
- Contact:
Re: Batch Crossing Over
Do want all the same functionality as ansi or just the cursor feature?
Stop changing your post it is wigging me out, all these god damn ghost in the machine are starting to scare me.
Stop changing your post it is wigging me out, all these god damn ghost in the machine are starting to scare me.
Re: Batch Crossing Over
Do want all the same functionality as ansi or just the cursor feature?
Euhhhh, I can't choose
Can I have both
Re: Batch Crossing Over
Hey guys
I haven't seen any perl on this post yet. I can't contribute any since its been years since I used it on one project, but I remember it was powerful. Also confusing because of the million ways one could accomplish the same thing.
Dave
I haven't seen any perl on this post yet. I can't contribute any since its been years since I used it on one project, but I remember it was powerful. Also confusing because of the million ways one could accomplish the same thing.
Dave
-
- Posts: 287
- Joined: 16 Mar 2011 19:17
- Location: scriptingpros.com
- Contact:
Re: Batch Crossing Over
Perl for what...? I know you can but I never understood why people still use things like perl, jscript, to preform client side task. What dos are we translating to perl, go ahead be a smart a$$ and give me something in DOS and I will translate it to perl. Oh I asked for it now and it is coming.
-
- Posts: 287
- Joined: 16 Mar 2011 19:17
- Location: scriptingpros.com
- Contact:
Re: Batch Crossing Over
Ed Dyreen wrote:I don't wan't to add ansi.sys as device driver.
And even if I did I don't know if it would work.
The purpose, depends on the latency, if it is to slow, not much.
It does replace constructions likeCode: Select all
cls &echo.he &@sleep 50
cls &echo. l &@sleep 50
cls &echo.hello &@sleep 50
loop
Yeah and it also states the obvious http://support.microsoft.com/kb/101875
Recoding the wheel is a waste and you know it. Especially if something is built already go get the powershell already. You will be happy with the outcome, you may not like it now but you will.
-
- Posts: 287
- Joined: 16 Mar 2011 19:17
- Location: scriptingpros.com
- Contact:
Re: Batch Crossing Over
Taking an array in csharp and getting down to just a single line of Powershell
Create an array, loop through them, take each element calculate its length, accumulate it and print it out
Now we put this inside of a here string and we use the cmdlet Add Type which will compile it for us
We will also add public to class and static method main
Now we have to call it in a fully qualified way and we will pass null as an arg
This is how we drop a csharp program into powershell
Now lets make it a little more powershell friendly.
We can get rid of the namespace, class, and method.
...but we can still reduce this even more.
We can now indroduce a function to get this down one line of pshell
Create an array, loop through them, take each element calculate its length, accumulate it and print it out
Code: Select all
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string[] items = new string[] ("john", "jim", "nancy", "bobo" );
int totalLength = 0;
foreach (string item in items)
totalLength += item.Length;
Console.Write("The total (0)", totalLength);
}
}
}
Now we put this inside of a here string and we use the cmdlet Add Type which will compile it for us
We will also add public to class and static method main
Code: Select all
Add=Type
@*
using System;
namespace ConsoleApplication1
{
public class Program
{
public static void Main(string[] args)
{
string[] items = new string[] ("john", "jim", "nancy", "bobo" );
int totalLength = 0;
foreach (string item in items)
totalLength += item.Length;
Console.Write("The total (0)", totalLength);
}
}
}
*@
Now we have to call it in a fully qualified way and we will pass null as an arg
Code: Select all
[ConsoleApplication1.Program]::Main($null)
This is how we drop a csharp program into powershell
Now lets make it a little more powershell friendly.
We can get rid of the namespace, class, and method.
Code: Select all
$items = "john", "jim", "nancy", "bobo"
$totalLength = 0
foreach ($item in $items) {
$totalLength += item.Length
}
"The total (0)" =[ $totalLength)
...but we can still reduce this even more.
Code: Select all
$items = "john", "jim", "nancy", "bobo"
foreach ($item in $items) {
$totalLength += item.Length
}
"The total $totalLength" // We can embed a var inside of a str
We can now indroduce a function to get this down one line of pshell
Code: Select all
function list ( $args )
Code: Select all
list john jim nancy bobo | foreach () ( $totalLength += $_.length ) ("The total $totalLength")
Re: Batch Crossing Over
I'm still in XP era, but it's very likely I'll support Win7 by the time Win9 comes out
I will then be able to use PShell, as it is native to 7
I will then be able to use PShell, as it is native to 7
-
- Posts: 287
- Joined: 16 Mar 2011 19:17
- Location: scriptingpros.com
- Contact:
Re: Batch Crossing Over
Win9 is not out yet?
strange
strange
Re: Batch Crossing Over
is out already, my god I did NOT know that
Nooo, it isn't !
Nooo, it isn't !
Microsoft's Next OS “Windows 8″ (Major Release) Coming in 2012 ...
-
- Posts: 287
- Joined: 16 Mar 2011 19:17
- Location: scriptingpros.com
- Contact:
-
- Posts: 287
- Joined: 16 Mar 2011 19:17
- Location: scriptingpros.com
- Contact:
Re: Batch Crossing Over
Some randomness as this thread is just that, but I think it was nit, or maybe orange that posted some php script, just curious on thoughts about this class.
Pros, cons? and how can it be improved.
Anyone who can point out the obvious ways of getting around this 5points.
What does this prevent and what does it allow.
Pros, cons? and how can it be improved.
Anyone who can point out the obvious ways of getting around this 5points.
What does this prevent and what does it allow.
Code: Select all
<?
class proxy_detector {
/**
* CONSTRUCTOR
* Set defaults...
*/
function proxy_detector(){
$this->config = array();
$this->lastLog = "";
//set default headers
$this->scan_headers = array(
'HTTP_VIA',
'HTTP_X_FORWARDED_FOR',
'HTTP_FORWARDED_FOR',
'HTTP_X_FORWARDED',
'HTTP_FORWARDED',
'HTTP_CLIENT_IP',
'HTTP_FORWARDED_FOR_IP',
'VIA',
'X_FORWARDED_FOR',
'FORWARDED_FOR',
'X_FORWARDED',
'FORWARDED',
'CLIENT_IP',
'FORWARDED_FOR_IP',
'HTTP_PROXY_CONNECTION'
);
}
/**
* VOID setHeader( STRING $trigger )
* Set new header trigger...
*/
function setHeader($trigger){
$this->scan_headers[] = $trigger;
}
/**
* ARRAY $triggers = getHeaders( VOID )
* Get all triggers in one array
*/
function getHeaders(){
return $this->scan_headers;
}
/**
* VOID setConfig( STRING $key, STRING $value)
* Set config line...
*/
function setConfig($key,$value){
$this->config[$key] = $value;
}
/**
* MIXED $config = getConfig( [STRING $key] )
* Get all config in one array, or only one config value as a string.
*/
function getConfig($key=''){
if($key)
return $this->config[$key];
else
return $this->config;
}
/**
* STRING $log = getLog( VOID )
* Get last logged information. Only works AFTER calling detect()!
*/
function getLog(){
return $this->lastLog;
}
/**
* BOOL $proxy = detect( VOID )
* Start detection and return true if a proxy server is detected...
*/
function detect(){
$log = "";
//scan all headers
foreach($this->scan_headers as $i){
//proxy detected? lets log...
if($_SERVER[$i])
$log.= "trigger $i: ".$_SERVER[$i]."\n";
}
//let's do something...
if($log){
$log = $this->lastLog = date("Y-m-d H:i:s")."\nDetected proxy server: ".gethostbyaddr($_SERVER['REMOTE_ADDR'])." ({$_SERVER['REMOTE_ADDR']})\n".$log;
//mail message
if($this->getConfig('MAIL_ALERT_TO'))
mail($this->getConfig('MAIL_ALERT_TO'),"Proxy detected at {$_SERVER['REQUEST_URI']}",$log);
//write to file
$f = $this->getConfig('LOG_FILE');
if($f){
if(is_writable($f)){
$fp = fopen($f,'a');
fwrite($fp,"$log\n");
fclose($fp);
}else{
die("<strong>Fatal Error:</strong> Couldn't write to file: '<strong>$f</strong>'<br>Please check if the path exists and is writable for the webserver or php...");
}
}
//done
return true;
}
//nope, no proxy was logged...
return false;
}
}
?>