Jump to content

skreien

Active Members
  • Posts

    50
  • Joined

  • Last visited

Everything posted by skreien

  1. I compiled the testpdh_cpuusage.au3 after downloading the newest version and tried it on my big server... it still reports the wrong cpu count. It's coming back with 32 and 20 CPU's on back to back runs.
  2. Just wanted to let you know that I traced the problem down to a call to a UDF. There is an updated version to fix other problems so I'm going to give that a shot.
  3. Yep, I wasn't kidding about the 80 procs. I've got some big toys to play with. That looks much better. # of Processors per GetSystemInfo = 60 # of Processors in Environment Var = 60 Number of Active processors = 80
  4. Thanks JohnOne for the idea, but it's being called periodically by another service so I'm not sure I'll be able to see the icon. I've marked the service as interactive so I'll see if it shows up.
  5. Matter of fact, now that I look at it it HAS to be the consolewrite. _WRITELOG("process array console write error") If $aProcessArray[0][3]=-1 Then ConsoleWrite("**CPU Usage** was not able to be obtained this go-around"&@CRLF) _WRITELOG("changed processes") The last thing written to the logfile was "process array console write error". Then it hung for 12 hours until I ended the task.
  6. I took the consolewrite out of it to see if that's causing my problem. It only hits it every few days though, so it will probably be a few days before I know. Kylomas: RIght now I'm not posting it because I'm trying to figure out if it's stopping in the call to the UDF, or if it's somewhere in what I've written. Until I know that I don't know what to ask for help with. I've added some code to write a log file as it executes so I can see the last step that executed before it locked up. That's what led me to the consolewrite. That was the very next instruction after the last logfile write.
  7. It's definitely screwy.... I ran it twice back to back and got different answers. The first time I got 20, second time I got 60. This is on Win2008R2 and compiled as 64 bit exe.
  8. I think I may have found the problem. I had a consolewrite in the app from previous efforts, even though it's not a dos application. It looks like whenever it hit the consolewrite it would just pause. not even the Adlib function could force it to exit. Anyone know if that's expected behavior, or a bug? I would suspect the latter.
  9. AdlibRegister looks like it can do exactly what I want. If it's been running for over a minute I can exit the script from there. Looks like a good way to run repetitive checks. I've never seen that function before. Thanks!
  10. Hey everyone, I have a compiled script that calls an older UDF. It works 99.99% of the time, but every great once in a while it will get stuck. Not sure why or how, but when it does I just want it to exit. Is there a way to set a timer that forces a script to exit after say 2 minutes regardless of its status? Obviously there's many ways to do it external to the script; I'm wondering if there's a way to do it internally? Things are evaluated from the top down, and if the script is stuck on a call and can't proceed, how can I just force it to exit? Thanks!
  11. I'm trying to use this on a Win2008R2 server with a total of 80 cores. It's coming back with idle of anything from 130% to 390%. Any ideas?
  12. Thanks James, I'll take a look. Mine does what I want it to, now I need to get an error handler put in. Right now when it runs out of objects in the playlist or the playlist is empty it crashes. Other than that it's working great.
  13. After I put the kids (and the wife ) to bed last night I sat down for some serious work. Here's what I have now. It tracks down anything that was last played over seven days ago that's in a playlist called WatchDelete. It retrieves the file path from iTunes, removes it from the main TV Shows library, then removes the file from disk. Still a work in progress though. #include <Date.au3> #include <File.au3> $LOGFILE="C:deletelog.txt" _FileWriteLog($LOGFILE, "Attaching to iTunes") $ITUNES = ObjCreate("iTunes.Application") If Not IsObj($ITUNES) Then ;Notify user if user does not have iTunes installed on his computer MsgBox(0, "", "ERROR: Could not create iTunes object." & @CRLF & @CRLF & "Explanation:" & @CRLF & "iTunes, or some of it's components, are not installed on your computer." & @CRLF & "Now Exiting..") Exit EndIf if @error Then _FileWriteLog($LOGFILE, "ERROR: Cannot attach to iTunes, exiting") Exit endif $ITUNESMUSICSOURCESTODELETE = $ITUNES.Sources $LIBRARYTODELETE = $ITUNESMUSICSOURCESTODELETE.ItemByName("Library") ; main library $PLAYLISTSTODELETE = $LIBRARYTODELETE.Playlists _FileWriteLog($LOGFILE, "Getting contents of playlist WatchDelete") $PLAYLISTTODELETE= $PLAYLISTSTODELETE.ItemByName("WatchDelete") ; Playlist to look for titles of tv shows to delete in the main library $TRACKNAMESTODELETE=$PLAYLISTTODELETE.Tracks for $TRACKTODELETE in $TRACKNAMESTODELETE $TITLETODELETE=$TRACKTODELETE.Name ;MsgBox(0,"title to remove",$TITLE) ;$TRACK.Delete ; deletes track from playlist _FileWriteLog($LOGFILE, "Found candidate to remove with title: " & $TITLETODELETE) $ITUNESMUSICSOURCESMAINLIB = $ITUNES.Sources $LIBRARYMAINLIB = $ITUNESMUSICSOURCESMAINLIB.ItemByName("Library") ; main library $PLAYLISTSMAINLIB = $LIBRARYMAINLIB.Playlists $PLAYLISTMAINLIB = $PLAYLISTSMAINLIB.ItemByName("TV Shows") ; search the TV Shows list (all TV Shows in the library) for a title matching this one $TRACKNAMESMAINLIB=$PLAYLISTMAINLIB.Tracks _FileWriteLog($LOGFILE, "Searching main library for a title match") for $TRACKMAINLIB in $TRACKNAMESMAINLIB $TITLEMAINLIB=$TRACKMAINLIB.Name if $TITLEMAINLIB = $TITLETODELETE Then _FileWriteLog($LOGFILE, "Found matching title, getting other info") $LOCATIONMAINLIB=$TRACKMAINLIB.Location _FileWriteLog($LOGFILE, "File is in location " & $LOCATIONMAINLIB) $PLAYEDDATEMAINLIB=$TRACKMAINLIB.PlayedDate $YEAR=StringLeft($PLAYEDDATEMAINLIB,4) $MONTH=StringMid($PLAYEDDATEMAINLIB,5,2) $DAY=StringMid($PLAYEDDATEMAINLIB,7,2) _FileWriteLog($LOGFILE, $TITLEMAINLIB & " was last played " & $YEAR & "-" & $MONTH & "-" & $DAY) $DAYSOLD=_DateDiff("D", $YEAR & "-" & $MONTH & "-" & $DAY, _NowCalcDate()) _FileWriteLog($LOGFILE, "Last play was " & $DAYSOLD & " days ago") $DELETERETURN=MsgBox(1,"Deleting title",$TITLETODELETE,5) if $DELETERETURN = 1 or $DELETERETURN=-1 Then _FileWriteLog($LOGFILE, "Delete approved or timeout approved") ;MsgBox(0,"return",$LOCATIONMAINLIB) ;MsgBox(0,"return",$PLAYEDDATEMAINLIB) ;MsgBox(0,"date",$YEAR & "-" & $MONTH & "-" & $DAY) ;msgbox(0,"Daysold",$DAYSOLD) if $DAYSOLD > "7" Then _FileWriteLog($LOGFILE, "Last play was more than 7 days ago, proceeding with delete") _FileWriteLog($LOGFILE, "Removing from iTunes") ;$TRACKMAINLIB.Delete ; deletes track from library entirely ;$TRACKTODELETE.Delete ; deletes track from playlist only _FileWriteLog($LOGFILE, "Removing from disk") ;FileDelete("$LOCATIONMAINLIB" EndIf EndIf EndIf Next Next $ITUNES = 0
  14. Thanks kylomas, I'll take a look. I edited my previous post to put the code into code tags. Like I said, I don't post very much. Thanks for the tip.
  15. OK, I got 75% of what I want.... here is the code so far. It functions as I wanted, except I haven't figured out how to remove from disk yet. This is much farther in two days than I've gotten in 2 weeks the last time I tried to do something like this. It's a very good thing this doesn't delete from disk yet. The first time I ran it I accidentally remove my entire TV Show library. That's fixed now. Present code below. $ITUNESMUSICSOURCESTODELETE = $ITUNES.Sources $LIBRARYTODELETE = $ITUNESMUSICSOURCESTODELETE.ItemByName("Library") ; main library $PLAYLISTSTODELETE = $LIBRARYTODELETE.Playlists $PLAYLISTTODELETE= $PLAYLISTSTODELETE.ItemByName("WatchDelete") ; Playlist to look for titles of tv shows to delete in the main library $TRACKNAMESTODELETE=$PLAYLISTTODELETE.Tracks for $TRACKTODELETE in $TRACKNAMESTODELETE $TITLETODELETE=$TRACKTODELETE.Name ;MsgBox(0,"title to remove",$TITLE) ;$TRACK.Delete ; deletes track from playlist $ITUNESMUSICSOURCESMAINLIB = $ITUNES.Sources $LIBRARYMAINLIB = $ITUNESMUSICSOURCESMAINLIB.ItemByName("Library") ; main library $PLAYLISTSMAINLIB = $LIBRARYMAINLIB.Playlists $PLAYLISTMAINLIB = $PLAYLISTSMAINLIB.ItemByName("TV Shows") ; search the TV Shows list (all TV Shows in the library) for a title matching this one $TRACKNAMESMAINLIB=$PLAYLISTMAINLIB.Tracks for $TRACKMAINLIB in $TRACKNAMESMAINLIB $TITLEMAINLIB=$TRACKMAINLIB.Name if $TITLEMAINLIB = $TITLETODELETE Then $DELETERETURN=MsgBox(1,"Deleting title",$TITLETODELETE,5) if $DELETERETURN = 1 or $DELETERETURN=-1 Then MsgBox(0,"return",$DELETERETURN) $TRACKMAINLIB.Delete ; deletes track from library entirely ;$TRACKTODELETE.Delete ; deletes track from playlist only EndIf EndIf Next Next
  16. OK, so I finally figured out how to get the track name. I've seen in several places track removal, so that's next. $objApp = ObjCreate("iTunes.Application") $colSources = $objApp.Sources $objSource = $colSources.ItemByName("Library") $colPlaylists = $objSource.Playlists $objPlaylist = $colPlaylists.ItemByName("Test") $TRACKNAMES=$objPlaylist.Tracks for $TRACK in $TRACKNAMES ;$objPlaylist.LibraryPlaylist.Tracks.ItemByName($TRACK.Name).Delete $TITLE=$TRACK.Name ;MsgBox(0,"title",$TITLE) $objSource.$TRACK.Delete Next
  17. Thanks I've been looking at it also, but the thread says it doesn't work on iTunes 10 so other than trying to figure out how to use COM I haven't relied on it for anything.
  18. Hi everyone, I've been an AutoIt user for 10 years, on and off. I've done tons of stuff with it, but I've never done anything with COM. As they say, need is the mother of invention, so now I'm trying to automate iTunes. Here's my situation: I use MythTV to record everything and transcode it into AppleTV format, which then drops it into iTunes. iTunes acts as the media manager. Unfortunately there's no way to auto-remove recordings that I've watched and don't want anymore. So I'm trying to write an AutoIt script that pulls the list of shows from a smart playlist, currently called test (the smart playlist is to make it easier to control what shows get removed), and deletes the files from the library and the disk. Here's what I have so far. It works down to the for statement. $objApp = ObjCreate("iTunes.Application") $colSources = $objApp.Sources $objSource = $colSources.ItemByName("Library") $colPlaylists = $objSource.Playlists $objPlaylist = $colPlaylists.ItemByName("Test") for $TRACK in $objPlaylist.Tracks $objPlaylist.LibraryPlaylist.Tracks.ItemByName($TRACK).Delete Next I've downloaded all the examples I can find but I am really stuck. I can script fairly well, but COM seems to be beyond me. I'd appreciate some help with getting this written and working. I don't post very often so I wasn't sure if I should put this in the COM forum, but since it's not AutoITX I decided to try here. Thanks!
  19. I meant, if I don't have one open and someone else does. Or even if I have one open in another session, but not in the current session. Terminal services gets a bit strange sometimes, things don't always react like you'd expect.
  20. How does ObjGet("", "Outlook.Application") react in a terminal server environment? Will it only connect to yours, or will it connect to someone elses if it's running since it's on the same machine? I'm a bit leery of doing this in terminal services.
  21. Thanks water, but I wanted to do it myself. I wanted to get a better understanding of com objects. Although if yours waits for outlook to exit in some way I would like to borrow that code from you if you don't mind.
  22. Hey guys, I have a program that interfaces with and sends email via Outlook. Except it doesn't send it, it just puts it in the outbox. So I'm using com to force a send/receive operation whenever that other program exits, or every 15 minutes otherwise. I have all that working. The problem I have is, how do I make sure that Outlook has exited before my script exits? I send Outlook the quit command, and it does seem to quit, but my script always exits first. Since this is for non-technical users I need the script to wait until Outlook exits or my users will get confused. This is in terminal services environment so there can be multiple Outlook processes running, so I can't search for Outlook's process ID. I need to either: 1. get my specific Outlook PID from the com object, or... 2. make the script wait until the Outlook com object exits Any help with either would be great. This is my first use of com objects, so go easy on me. Thanks!
  23. OK, here is how it's done in powershell. Looks like they're reading the stream that comes back after socket shutdown. How can I do that with AutoIt? $socket.Client.Shutdown(1) # Signal to Xymon we're done writing. $s = new-object system.io.StreamReader($stream,"ASCII") start-sleep -m 200 # wait for data to buffer $outputBuffer = $s.ReadToEnd()
  24. Now that I'm back at work, here's the code I'm using. This is just a test file to try and get the idea working, but it's basically what I'm trying to do. Local $XYMONHOST="10.170.1.200" Local $XYMONPORT="1984" Local $LOCALPORT Local $LOCALIPADDRESS Local $LOCALSOCKETSEND Local $LOCALSOCKETRECEIVE Local $LINETOSEND Local $LINERECEIVED Dim $TCPTABLE Local $ConnectedSocket = -1 Local $i Local $FILESIZE TCPStartup() $LOCALSOCKETSEND=TCPConnect($XYMONHOST,$XYMONPORT) if $LOCALSOCKETSEND=-1 Then ConsoleWrite("Socket not connected") Else $TCPTABLE=_GetTCPtable() For $i=1 to $TCPTABLE[0][0] if $TCPTABLE[$i][3]=$XYMONHOST and $TCPTABLE[$i][4]=$XYMONPORT Then $LOCALPORT=$TCPTABLE[$i][2] $LOCALIPADDRESS=$TCPTABLE[$i][1] ConsoleWrite("$LOCALIPADDRESS=" & $LOCALIPADDRESS & @CRLF) ConsoleWrite("$LOCALPORT=" & $LOCALPORT & @CRLF) ExitLoop EndIf Next $LINETOSEND="client test,hq.bbwin win32" TCPSend($LOCALSOCKETSEND,$LINETOSEND) ;TCPCloseSocket($LOCALSOCKETSEND) $LINERECEIVED=TCPRecv($LOCALSOCKETSEND,4096) ;$LOCALSOCKETRECEIVE=TCPListen($LOCALIPADDRESS,$LOCALPORT,100) ;Do ; $ConnectedSocket = TCPAccept($LOCALSOCKETSEND) ;Until $ConnectedSocket <> -1 ;$LINERECEIVED=TCPRecv($LOCALSOCKETRECEIVE,4096) EndIf ConsoleWrite("$LINERECEIVED=" & $LINERECEIVED & @CRLF) TCPShutdown() The problem is that this TCP sequence goes like this: SYN SYN ACK ACK send my client data now RST, ACK ACK RST a FIN is never sent, so the server never replies with its data.
×
×
  • Create New...