#181083 - 2007-10-03 03:53 PM
redirectoutput and blat
|
booey
Getting the hang of it
Registered: 2005-07-25
Posts: 76
Loc: USA
|
Hi everyone. I am trying to create a script that will get a list of all filenames in a directory, output that list to a file and then send it with blat. I can create the file fine, but when I try to send it with blat, I get the error: "unknown error code 32 when trying to open C:\temp\kix\kixtest.txt" Here is my code so far.
BREAK ON
DIM $faildir,$faildirplus,$body,$file
$faildir ="\\server\share\folder\"
$faildirplus = dirplus($faildir,"/a-d /f tif")
For Each $file In $faildirplus
If RedirectOutput("C:\temp\kix\kixtest.txt",0) = 0
? $file.name
;@SERROR
Else
EndIf
Next
Sleep 1
Shell '\\server\netlogon\Programs\blat.exe C:\temp\kix\kixtest.txt -t recipient@domain.com -f sender@domain.com -server mailhost.com -subject "Test"'
Also, I'm using redirectoutput to create the file because I couldn't figure out how to get each filename to populate in the file using writeline. If writeline is the better method, please let me know.
Does anyone have any idea why I'm getting the error when trying to send? It seems like the file might still be in use.
Thanks.
|
Top
|
|
|
|
#181085 - 2007-10-03 04:09 PM
Re: redirectoutput and blat
[Re: booey]
|
eriqjaffe
Hey THIS is FUN
Registered: 2004-06-24
Posts: 214
Loc: Arlington Heights, IL USA
|
I usually use the WriteFile() UDF to pump an array out to a text file, myself. I find it to be a bit cleaner than RedirectOutput() or WriteLine().
|
Top
|
|
|
|
#181093 - 2007-10-03 09:10 PM
Re: redirectoutput and blat
[Re: Richard H.]
|
booey
Getting the hang of it
Registered: 2005-07-25
Posts: 76
Loc: USA
|
Thanks for the input. I'm trying to use the writefile function, but I can't get the array to write to the file. It creates the file ok, but it's blank. Can you tell me what I am doing wrong?
BREAK ON
DIM $faildir,$faildirplus,$body,$file,$wf,$wfstrip
$faildir ="\\server\share\folder\"
$faildirplus = dirplus($faildir,"/a-d /f tif")
For Each $file In $faildirplus
$wfstrip = stripsuffix($file.name)
? $wfstrip
Writefile("C:\temp\kix\test.txt",$wfstrip)
Next
When I output the $wfstrip to the screen, it shows me the filenames that I'm looking for, but they don't get put in the file. I'm sure it's something easy, but not for me apparently.
Thanks.
|
Top
|
|
|
|
#181096 - 2007-10-03 09:38 PM
Re: redirectoutput and blat
[Re: Gargoyle]
|
booey
Getting the hang of it
Registered: 2005-07-25
Posts: 76
Loc: USA
|
Yes, the UDF is in my code.
I tried using writeline initially, but only the first filename in the array was being written to the file. Here is my code when using writeline
$faildir ="\\server\share\folder\"
$faildirplus = dirplus($faildir,"/a-d /f tif")
For Each $file In $faildirplus
If Open(3,"C:\temp\kix\test.txt",5) = 0
WriteLine(3,$file.name)
Else
EndIf
Next
|
Top
|
|
|
|
#181104 - 2007-10-03 10:42 PM
Re: redirectoutput and blat
[Re: Glenn Barnas]
|
booey
Getting the hang of it
Registered: 2005-07-25
Posts: 76
Loc: USA
|
Hey, I never said I was good at scripting... I didn't see your reply when I replied back to the writeline response.
The $file.name returns just the filename, whereas $file returns the whole path. I don't want the whole path, just the filename. I'm using file.name in my script now and it works just fine.
|
Top
|
|
|
|
#181107 - 2007-10-03 11:08 PM
Re: redirectoutput and blat
[Re: Glenn Barnas]
|
booey
Getting the hang of it
Registered: 2005-07-25
Posts: 76
Loc: USA
|
Thanks for the suggestions. I'll start doing that with the "?".
I do appreciate everyone's help though. This board is a lifesaver and is very helpful for people like me.
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 515 anonymous users online.
|
|
|