Wednesday, June 11, 2008

I m not a Unix guy but am currently working with it. In one terminal I ssh into a machine- and then telnet into another. In this telnet I spawn an application that accepts commands. I send commands like "moveUp(10)" and others. I wanted to write a program to use on top of this so instead of typing that in- I could just press "up" 10 times- or some other key. Kind of like making shortcut keys. I was going to use perl. I was thinking I could just run the application in a different termnial window to register my key pressed- and have it post the textual commands to the telnet window. Is this possible- and if so how do I do it?

I created a form on an webpage. I then input parameters and submit the form to my perl cgi script. I want the script to create a KML file and prompt the user to save the KML file from Internet Explorer after submitting the form. So...in the perl script- instead of using open(OUTPUT- >outputfilename.kml) and using print OUTPUT "blahblah" for every print statement- do I just use print by itself to popoulate the file- and when its done IE will automatically prompt me to save it? I know that Google Earth uses this method when calling a cgi script. It just outputs the code back to Google Earth viewer simply with the print statement.
In my HTML form- I have <FORM ACTION="http://www.site.com/myscript.cgi>. So I call the script and in my script- I have

print "Content-Type: application/vnd.google-earth.kml+xml \n"
Content-Disposition: attachment; filename="outputfile.kml"\n\n

Are these the key elements I need to call the script? I submit the form and I get nothing back- so I am trying to figure out if it s something in my script. I do parse the $ENV{QUERY_STRING}- just to let you know.

this is what i have so far. (perl)
#!Z://perl

print "please enter the amount of money you would like to convert into coins. \n";
$money = <STDIN>;
$changequarter = $money / 25;
$CQ = int($changequarter);
$D = $money % 25;
$dime = $D / 10;
$DA = int($D);
$N = $D % 10;
$nickle = $N / 5;
$NA = int($nickle);
$P = $nickle % 5;
$penny = int($P);

print " you have $CQ quarters\n";
print " $DA dimes.\n";
print " $NA nickles\n";
print " and $penny pennys\n";

something is wrong with the dimes i think. can anyone be of help?

if(opendir(DIR-$directory)) { # Proess file with NGC
foreach my $filename1 (readdir DIR) {
if ($filename1 =~ /ngc.*\.xml$/i ) {
if (open(NGC_Input-$filename1)) {
$NGC_Update=$filename1;
close (NGC_Input);
}
}
}
}

Someone provided me with the code above to search for any file that has ngc on it. However the code provided also has a specific directory to look for. Is it possbile to remove the directory and just search for file. I tried editing it but nothing seems to work. I m just new in perl so can someone please help??? thank you

Using perl regex 5.8.0

Here is the expr...

(box start .*? (?!description) .*? box end)

with data...

(1)
<!-- GREY BOX START -->
ddsadsa fdsgfdwe ewqewq
dsadsa> dsa ds ds <dsadsa
<!-- GREY BOX END -->

(2)
<!-- GREY BOX START -->
dsa dsadas
dsadsa description.gif dsadsa
dsadf fdfsd
<!-- GREY BOX END -->

(3)
<!-- GREY BOX START -->
ddsad> adadsa dsa <dsadsa>
<!-- GREY BOX END -->

.. current result = 1-3 are matched

*** desired result = 1 and 3 to match by specifically exluding (2) ***
thanks :) the regex is part of a wider system- therefore- i really need a solution to be nailed in rexex only rather than use perl for conditional coding
Placing that into regexbuddy with my test data throws an error on the ?? (i.e. question mark question mark)

sorry- do you have an alternative for this token

major thanks for this- that sure is an ugly expression created with some love :) amazing- thanks a million

No comments: