Comatose 290 Taboo Programmer Team Colleague

Are You Saying I Rant? ;)

Comatose 290 Taboo Programmer Team Colleague

Appreciate The Input, and you are correct, that would work..... not to be too much of a stickler though, this IS a Perl forum, and not a shell scripting forum. We have one of those here: http://www.daniweb.com/techtalkforums/forum113.html, that has a bunch of shell scripting posts.

Thank you.

Comatose 290 Taboo Programmer Team Colleague

Sure, but you should only need 1 set of parenthesis, and you might have to escape them, I'm not sure... (by escaping, I mean making it a literal character using \, such as \(, but I'm not positive you have to). But you have the idea straight up.... just search the string for what you are looking for, and then run the split if it's true. You could also look at using your own custom function, but I think you hit the nail on the head with the pattern matching regex above.

Comatose 290 Taboo Programmer Team Colleague

Wait, I'm still confused..... this program needs to copy files from windows to linux.... ok good. Now, we have Samba setup. Samba lets us share a directory between windows and linux.... ok great... you have 2 shares....downloads and sctdata, and these two shares.... go to /var/www/list and /var/www/lot_repos respectively. So far still so good.... so, if the windows box or windows user copies files to the downloads or sctdata share.... I'm seeing them automagically show up in /var/www/list and /var/www/lot_repos.... right? So Samba is doing all the work so far.... it's even copying the files from windows to linux right? So, if not mistaken, the perl program has no need to do anything other than chmod files, and print a report right?

Comatose 290 Taboo Programmer Team Colleague

I would personally use split..... if you know that the line will look like that most of the time, it's easy enough to split it like so:

($junk, $rest) = split(/\(/, $_); # $_, or whatever variable contains the string
push @numarray, substr($rest, 0, 1);

Now, the array numarray will contain those numbers.... and you can do a:

foreach $num (@numarray) {
     print "$num\n";
}

Or Reference The Array in Scalar context, such as $numarray[0]. Let me know how that works for you.

Comatose 290 Taboo Programmer Team Colleague

Do me a big favor... when you post, use code tags. You can do that like this
[ CODE]
dim ADO as object
[ /CODE]

with no spaces between the [ and the word or /. Anyway, it helps to make the posts a little bit more readable, and helps make the post more organized. Thanks.

Comatose 290 Taboo Programmer Team Colleague

The Number in the ()? In This Case 1?

Comatose 290 Taboo Programmer Team Colleague

One Possible Solution, is to check and see if the app is already running. If it is, in fact, Word that is giving you grief, you could use a timer, for example, and search to see if the classname is open.... In a code module, add this:

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Then in your timer, or whenever you want to check for word, you can simple call findwindow on the classname of word, and if findwindow returns 1, then you know word is open... the class of word is: OpusApp, for Word Xp... You can run this little tool I built to grab the classname of just about any window from here:
http://www.aftermath.net/~coma/downloads/getclass/

The Source to search to see if word is running, would be something like this:

retval = findwindow("OpusApp", vbnullstring)
if retval <> 0 then
     msgbox "Found Word"
end if

You can then check to see if it's open at any time, so that way you know what the default behavior is going to be. You might also consider looking into using the word.application class, and instantiate an instance of it for your app.... You can spawn word like this:

Dim Word
Set Word = CreateObject("Word.Application")
Set doc = Word.Documents.Add("c:\path2worddoc\somedocument.doc")
Word.Visible = True

There are other methods that work with the Word and Doc object.... a bunch of methods and a bunch of properties...here is the resource for …

Comatose 290 Taboo Programmer Team Colleague

Here is a fantastic tutorial covering the use of ADO with Visual Basic.... This should help quite a bit:
http://www.timesheetsmts.com/adotutorial.htm

Comatose 290 Taboo Programmer Team Colleague

Ok, What Directory on the unix box is the windows share mounted on? (what is the unix path to the samba share)?

Comatose 290 Taboo Programmer Team Colleague

I'm not a C guy by any means, but I think you can cast it.... such as:

newvar = (int)x + (int)y;

Someone who Codes a lot of C, please check this over...

Comatose 290 Taboo Programmer Team Colleague

http://www1.cs.columbia.edu/~lennox/perlre.html is a great site to learn about using multi-line regex's with Perl. There are a few methods there that can be used, the older, depreciated method is to set $*, but the newer methods, as of Perl 5, use an m and or s modifier.

Let me know what you come up with.... so that other people with similar problems can find the resolve here.

Comatose 290 Taboo Programmer Team Colleague

If you are using IE, I believe there is a content manager. It won't keep out of all porn sites, but it will certainly cut off a good portion of them.... the point being, it will require a lot more work to get to them.... you could consider using something like cybernanny, or another content manager....

Comatose 290 Taboo Programmer Team Colleague

I have a nice page for you to look at regarding "regular expressions" or "regex". Now, Regex is nice, but can be a bit confusing. Line Noise, as it's been called, can do magic, however, with a correctly set up expression, or expressions. I see that you tried with "m" which is the regular expression for "matching". In Perl, it defaults to m, so you could have done the same with just // instead of m//, but it's always better for readable to use the m. Here is a great page to learn and understand regex:

http://www.troubleshooters.com/codecorn/littperl/perlreg.htm

I hope this helps some. If you are still having mad troubles with it, I'll be glad to take a look at your code, and offer what help I can. Also, I don't see you opening a file to read the input from. The while (<>) { actually is trying to read input from STDIN, unless you have changed that somewhere previously.

open(FH "/home/mydir/somefile.txt");
     while (<FH>) {

     }
close(FH);

The Above is the best way IMO to go about this. It helps in readability... you are opening the file, using the filehandle FH. Then, In The While Loop, You Are Reading from FH (<FH>), line by line until it finds the EOF (end of file) character.

Also something to consider, is using the split function to get each of the information in the file in such <stuff here in your file>. For example, when I parse an …

Comatose 290 Taboo Programmer Team Colleague

Yes, It Is A Perl Forum.... But Nice Script.

Comatose 290 Taboo Programmer Team Colleague

:) That's Great!!!!!

Comatose 290 Taboo Programmer Team Colleague

Yes, Perl Counts Spaces as 1 character...and you can modify the above sub to count from the begining of the string, and loop until it finds a normal character. The one above finds trailing white spaces.... so, it starts from the very right of the string, and loops until there are no more tabs, spaces, or newline characters trailing "normal characters". As soon as the loop reaches something that is NOT a space or a tab or a newline character, it stops the loop. To have the loop start from the begining, then you would have to modify the loop quite a bit... because I use chop to shorten the string after the white space is counted... you would have to make your own function to chop the string at the begining and work that way....

Comatose 290 Taboo Programmer Team Colleague

Here is some code for you to count the number of "white spaces" in a file at the end of the string... the sub (function) classifies white spaces as space, tab, and newline.... you can modify the source accordingly, should it only be spaces, or only be tabs, or both... or any combo....

$file = $ARGV[0];

if ($file eq "") { 
	exit;
}


$wspace = 0;
open (FH, "$file");
	while (<FH>) {
		$nums = &count_trailing_white_spaces($_);
		$wspace += $nums;		
	}
close(FH);

print "There Are: $wspace White Spaces\n";

exit;





sub count_trailing_white_spaces
{
	$thestring = shift;
	my $wspacecnt = 0;

	while (substr($thestring, length($thestring) -1, 1) eq " " || substr($thestring, length($thestring) -1, 1) eq "\t" || substr($thestring, length($thestring) -1, 1) eq "\n") {
		$wspacecnt++;
		chop($thestring);
	}	

	return $wspacecnt;
}

Hope This Helps.

Comatose 290 Taboo Programmer Team Colleague

You aren't the first to duplicate post ;)

Ok, In C, you can CAST a Variable with this syntax:

(type)variable

So, For Example, Let's say that you want to take the floating point number x, and use it as an integer:

float x = 1.1;
int y = 2;
answer = (int)x + y;

Now, I try not to code in C much, and my syntax could be a bit off... but that should took the floating point variable x, and cast it as an integer, and add it with y. So, you can cast any type as far as I know. The types that I know of are:

char
short
int
long
float
double
long double

Hope this helps.... and let me know if you need anything else. I'll also talk to an admin about WHERE this thread should go.... it seems to me it's a vb app right?

Comatose 290 Taboo Programmer Team Colleague

I don't understand exactly what you mean. I can tell you that spaces, tabs, and newline characters qualify as white spaces..... if you would like sample code, that tells you how to count the number of white spaces.... then that's a different story.

Comatose 290 Taboo Programmer Team Colleague

The reason I said this, is because it's very possible to use what's called "CRON" to have the script run at certain times and/or certain dates. On your Unix Machine, Do A man on cron: man cron
It will give you a whole lot of information about setting up any script or program to run at a certain date and time.... I can help you with all the other things.... chmoding, and moving the files (I think....I'm not sure how you reference a samba partition, is just mounted in a folder?)....

Comatose 290 Taboo Programmer Team Colleague

Don't tempt me ;)

Comatose 290 Taboo Programmer Team Colleague

Well, I was winking at you (;)) and it would not let me post it, because in order to post, you have to have at least 10 characters.....

Comatose 290 Taboo Programmer Team Colleague

This thread was also posted in the perl forum...

Comatose 290 Taboo Programmer Team Colleague

do you get an error?

Comatose 290 Taboo Programmer Team Colleague

Is This a homework project, or something for work, or something for yourself? This makes a difference in the approach that you will have to take in order to make some of the options work a specific way.

Comatose 290 Taboo Programmer Team Colleague

*Has A Headache Just Thinking About It*

Understand, that this will be the bloodiest, most brutal war in computer history.... as long as you are aware of this....Seeing That VB Misses A HUGE number of things that C is able to accomplish. You don't have pointers, you don't have structs or unions... user defined types... sure. Then you have to take into account that strings in VB are NOT (well they are internally, but not in any helpful form to you) array's of type char. However, here is how you can cast things in VB:

Cint(expression) casts expression to an integer. If expression is a floating-point value or a currency value, it is rounded. If it is a string that looks like a number, it is turned into that number and then rounded if necessary. If it is a Boolean value of True, it becomes a -1. False becomes 0. It must also be within the range that an integer can store.

Cbyte(expression) casts expression to a byte value provided that expression falls between 0 and 255. expression should be numeric or something that can be cast to a number.

Cdbl(expression) casts expression to a double. expression should be numeric or something that can be cast to a number.

Csng(expression) casts expression to a single. It works like Cdbl(), but must fall within the range represented by a single.

Cbool(expression) casts expression to a Boolean value. If expression is 0, the result is False. …

Comatose 290 Taboo Programmer Team Colleague

;)...

and uh, there is 10 character limit on posts!

Comatose 290 Taboo Programmer Team Colleague
' /* Dimension Object Variables */
Dim ojbExcel

' /* Create The Object */
Set objExcel = CreateObject("Excel.Application")

' /* Actually Open The File */
Set objWorkbook = objExcel.Workbooks.Open("c:\path2your\file.xls")

' /* Choose Which Worksheet (or Tab) We Are Working With */
objExcel.ActiveWorkbook.Sheets(1).Select()

' /* Read The Value From The Cell At Row 2, Column 1 */
CellValue = objExcel.Cells(2, 1).Value

' /* Change The VAlue Of The Cell At Row 1, Column 1 */
objExcel.Cells(2, 1).Value = "Fun"

' /* Actually Show The Excel Window */
objExcel.Visible = true

' /* I Don't Care Who You Are, When You Use Objects, Always Unload Them */
set objExcel = nothing
Comatose 290 Taboo Programmer Team Colleague

Thats.... Profound.

Comatose 290 Taboo Programmer Team Colleague

You are slightly mistaken.... I have successfully created a VB app, that will sendkeys to both an msn messenger window, a yahoo messenger window, and a chat embeded into a web page on MSN, using {ENTER}, instead of vbcrlf..... also, you could use "vbnewline" for readability... vbcrlf is the vb constant of carriage return, and linefeed combined.... on most windows systems this is the standard for the newline character... which vbnewline (and {ENTER}) encompass.

Comatose 290 Taboo Programmer Team Colleague

No No, Not at all. The only stupid question is the one you don't ask. I just thought it would be fun to be a Shaolin of VB :D

Anyway, here is a good page to read up about sendkeys... there used to be a lot more, this one took some digging. I suppose I'll have to write one for Daniweb... Anyhow, you use it just by calling it, but it needs keys to send:

sendkeys "hi"

The Problem is, That It has codes that can go with it. For Example:

sendkeys "~{F4}{ENTER}"

Is The Same As Pressing Alt-F4, And Then Enter, at the same time. Alt F4 closes the currently active App, and Enter would be pointless.... but for an example for you to see, I put it there like that. I'm guessing you would do something like:

sendkeys ":){ENTER}"

Either way, Here is a page that lists the special characters, and the stuff you can put in braces:
http://www.scriptlogic.com/Kixtart/htmlhelp/Functions/sendkeys.htm

Let me know how it turns out.

Comatose 290 Taboo Programmer Team Colleague

it sounds to me like you have it figured out. Sometimes it's a bit more complex than we would like it to be.... or that we originally thought. Sorry I couldn't have given you more assitance on this matter.... but I'm a little confuzzled with it myself.

Comatose 290 Taboo Programmer Team Colleague

*Sits Here Like an Old Wise Shaolin VB Monk*

Use..... Sendkeys.

Comatose 290 Taboo Programmer Team Colleague

Good, Good, Now, what's wrong with this?

Dim words(25,[B]3[/B])
.
.
.
words(0, 0) = "@"
words(0, 1) = "/\"
words(0, 2) = "^"
words(0, 3) = "4"
[B]words(0, 4) = "a"
words(0, 5) = "A"[/B]

Also, A Lot of people who are used to programming in VB, get a little mixed up when they are using VBScript. Just like you can't use "as string" in a VBScript, you also can't give an identifier for a for loop's next. So, just remove the i after next... and it will run the loop correctly...

Comatose 290 Taboo Programmer Team Colleague

It's always a pleasure :)

Comatose 290 Taboo Programmer Team Colleague

If you are running this in VBScript, Instead of actual VB, then you have to remove the as strings. In VBScript, everything that is a data type (every variable, function, sub, return value) is a "variant" data type, and it can not be changed. In regular VB, you can dim X, and X is now a "variant" data type, it's the same as dim x as variant. VBScript only uses variants, it has no knowledge of things such as strings, integers, doubles, etc. If you were to put the exact same code in a VB 6 Program, it would work fine.

I'm not going to go into great detail about Arrays, or multi-dimensional arrays, but you are probably correct, it should most likely be declared from 0 to 25. Also, the number 3 is used, (again starting at 0), because there are 4 different options for the program to choose from to make it a B. I can be 8, |3, |}, and B, count 'em, there's 4 (0 through 3). If you add another one, then the array would have to be 4 (5 items). This line here:

intRnd = Int(Rnd * 3)

Says, give me a random whole number between 0 and 3, so yes, if you choose to change 1 of them to contain 5 different options for the program to choose from, then you will need to modify them all, including the line of code above, along with: Dim words(26, 3), to …

Comatose 290 Taboo Programmer Team Colleague

Well I would suggest getting the length of the wav file.... how long it plays in seconds, and then stick a timer control on your form, with it's interval set to 1000. That way the timer executes every second, and you set a static or public variable to increment every second. If the variable size is the same as (use greater than or equal to) the size of the file in seconds, don't try to play the next one, otherwise just exit sub.... that's how I would go about doing it.

Comatose 290 Taboo Programmer Team Colleague

Sorry about that.....

*mumbles something about countless windows versions*

Comatose 290 Taboo Programmer Team Colleague

http://www.microsoft.com/downloads/winGenuineDecision.aspx?FamilyId=321cd7a2-6a57-4c57-a8bd-dbf62eda9671&DisplayLang=en

I was able to download Microsoft Antispyware beta free of charge and no problems. It also seems to run pretty decently (I'm guessing because GIANT actually wrote it). Eitherway, they both are good, and will help thwart off spyware.

Comatose 290 Taboo Programmer Team Colleague

I would say that a quick scan of google for the filenames that are in question would result in a pretty good answer.....

Moneystartup = Microsoft Money
scanregistry = Microsoft's Registry Checker
* http://castlecops.com/startuplist-3215.html
taskmonitor = Checks Disk Access Patterns/how often programs are used
PCHealth = Apparently Automatic Updates From MS and Such
Systemtray = Seems To Be The System Tray
Loadpowerprofile = Microsoft Power Management Module
hidserv = Human Interface Device Service (Microsoft usb stuff)
countryselection = Country Selection For A Modem, not needed
PCTVoice = Used by the modem to interface with your computer
CPQeasyACC = Allows programmable keys on mulimedia keyboards
EACLEAN = Easy Access button support for the keyboard
Worksfud = A marketing program for MS Works
Microsoft Works portfolio = The MsWorks Portfolio Manager
Microsoft Works Update detection = Checks For New Versions of Ms Works
CPQINET = Lets AOL and Compuserve use Easy Access for the internet
Digital dashboard = Outlook Stuff (such as news, stock quotes, and so on)
tour = Probably A Tour of Windows Or Some Other Program
load power profile = Same As The First One
* http://castlecops.com/startuplist-1899.html
schedlingagent = Used For Scheduling Defrag, and other tasks
* If The Name Was NOT mistyped when you entered it
* Then You Might Want To Check If It's Spyware Or Not
statemgr = …

Comatose 290 Taboo Programmer Team Colleague

Ok, The information that the web page retrieves, I need to know what kind of file format they are in. I understand they will be text, but I need to know the format of it, such as:

url <TAB> referer <TAB> howmany

or will it be something like:

url
referer
howmany

or will they be in different text files, or how is this supposed to work. I can modify the script to work with the text files, but I need to understand how you will have it laid out. Let me know.

Comatose 290 Taboo Programmer Team Colleague

I see this is your first post, So, Welcome To Daniweb, and I hope you enjoy the site. One favor I am going to have to ask you, right off the bat, is not to piggy or resurrect ancient threads. This thread has been dead for a year, and it's best (and proper) to start your own thread if you have a question. Thanx, and I hope to be able to be of assistance to you.

Comatose 290 Taboo Programmer Team Colleague

Not that it's necessary to change something that works (believing this may be a perl sin, so i'll say a perl prayer later...) but you can change those two lines into one and eliminate the extra variable:

$FORM{'story'} =~ s/\n/<BR>/gi;

Kordaff

Yes Indeed, and in my previous post:

ps: I think you could have left the $story variable out of it, and ran the regex on the hash (associative array), but this allows you to keep the original data read from the file unchanged.... and then must use a new variable for the changes....

Comatose 290 Taboo Programmer Team Colleague

You can do it that way, but you'll need to change intRnd = Int(Rnd * 3) to 4, and that should work (adding it to the array). So, if you just add the upper and lower case versions to the array, and change the rnd seed between 4 instead of 3, it should work. Just fine for randomly selecting upper and lowercase, or special characters. As for the DIM, you don't even really need it in VBScript, just make your file look like my last post (the one that I responded to your "how to use it" question.)

Comatose 290 Taboo Programmer Team Colleague

I've just built an APP in VB6, That has 4 Buttons and 2 listboxes. The buttons are for quitting, clearing the listboxes, and then 1 for randomize without timer, and 1 for randomize with timer. listbox1 contains the result of a randomize without timer, and a for loop from 0 to 20 (21 items), that adds the result of the random seed to listbox1. listbox2 contains the result of a randomize WITH timer, and a for loop from 0 to 20 that adds the result of the random seed gathered with timer added to randomize, to listbox2. I haven't yet gotten a duplicate result.

Comatose 290 Taboo Programmer Team Colleague

Well, it's a function, and can be used in VB or VBS. A Quick Breakdown, is that a function returns a value, so it would be something like this:

whatever.vbs:

Dim Secure as string

UnSecure = inputbox("Enter Your Password")
Secure = passGen(UnSecure)
msgbox "Your Secure Password is: " & Secure

WScript.Quit

Function passGen( password As String ) As String
                
                Dim words(26, 3) As String
		Dim strTemp As String
		Dim intRnd As Integer
		Dim result As String
		
                ' /*  Assign Similar Values For 'A' */
		words(0, 0) = "@"
		words(0, 1) = "/\"
		words(0, 2) = "^"
		words(0, 3) = "4"
		
                ' /*  Assign Similar Values For 'Z' */
		words(25, 0) = "Z"
		words(25, 1) = "z"
		words(25, 2) = "2"
		words(25, 3) = "2"
		
		' /*  What you need to do are assign all 
		' the similar of each letter of the alphabet */
		
		Randomize
		
		' /* start generate each character
		' into secure character. */
		
		For i = 1 To Len(password)
		
			' /* store the current character
			' that we try to convert */
			
			strTemp = Mid(password, i, 1)
			
			' // Random similar letter of alphabet
			intRnd = Int(Rnd * 3)
			
			' /* if it is a alphabet then
			' we will replace it with similar string */
			
			If UCase(strTemp) <> LCase(strTemp) Then
			
				' /* start replace similar word into string */
				result = result & words(Asc(UCase(strTemp)) - 65, intRnd)
			Else
				' /* if it isn't a alphabet
				result = result & strTemp
			End If
			
		Next i …
Comatose 290 Taboo Programmer Team Colleague

Ok.

The for loop For i = 1 To Len(password), says basically "for all the letters in their password", so, if their password is Dinner, it's going to loop 6 times. Since the value of "i" will change every time it loops (starting at one, and ending with [in this example] 6), this line strTemp = Mid(password, i, 1), basically starts at the very left, and gets the first letter of the password, then the second, then the third (it changes, since it uses i, with each "iteration" of the loop) So, strTemp will actually be 1 character, and it will move through the person's password, character by character. Then it does a randomize, because you'll notice there are 3 or 4 possibilities for each letter to be altered to. That way D isn't always |), it can be |] also, so we grab a random number within our "letter range" of the array. Then basically we maintain a variable that we just add our information to the end of. So the variable result just keeps getting more letters added to it as we figure them out. This function (with the exception of the missing letters, E-Z) is fully functional, and once you add the missing letters will work as it is :)

Comatose 290 Taboo Programmer Team Colleague

Elise,

I'm A Soldier In The US Army, and we have army e-mail addresses. I rarely use it, but that isn't the point... my point is, that their is a standard restriction on how the password must be done for security reasons. That standard is that the password must contain 3 upper and 3 lower case characters, 2 "special characters" such as @#$%, and 4 numbers.

That said, I see No purpose, based on security reasons, for a need to change numbers, or special characters into anything else. If you really wanted to change the numbers into something else, then it would require the same concept that Visal coded above with the array. You'd have to increase the size of the array, to accept whatever numbers you want to catch, and change. Again though, my personal opinion is that special characters and numbers are pretty much secure enough to not need altering....

Another Thing To Consider, when using this script, is that most of the alterations that are made replace a single character with two characters. So, If A Password given by the user is "janetomandmatt", which is 14 characters, and M as translated to: /\/\, The password length, by just changing The First M, Is Now 18 characters long. If The Program that is requiring the password has a character cap of say 16 characters..... now what? Some programs will just truncate it.... (chop it off) so they could type the whole thing and it wouldn't …

Comatose 290 Taboo Programmer Team Colleague

Well, An Alternative Method is to use a filename for all your output, so, for example, in one program that I made, I needed all the Error Messages To Go To A Log File, So I stuck This at the top of my program:

open(STDERR, ">>log");

Then any error message that I needed to read, would be in the same folder as my script, in a file called "log". I think you can do the same for STDOUT, and have all output belonging to the screen redirected to a file also. Let me know how it turns out.