EvoTalk

Posts Tagged ‘Script

27 六月, 2007

Use TeraTerm Script

Posted by: asd In: 工作日誌| 科技新知| 軟體使用

需求:欲使用程式模擬 modem 三方通話的功能。
起初是打開 WinXP 內建的超級終端機,然後手動鍵入at command,測試 ok ,想寫成自動化的程式,本來是想說用 C 或 perl 來寫,打開 COM port,然後再送出 message。網路部門的同事建議使用 TeraTerm,它內建Tera Term Langauge(TTL),可以達到自動化的目的。
使用 TeraTerm 打開 serial port COM3,對 modem 作at command 測試
寫了如下的 script
view plain

CODE:

sendln 'ate1'               # 打開 echo

sendln 'atx0'               # 關掉 dialtone detection

 

while 1

wait 'RING'

sendln 'ath1'            [...]

Tags:

26 七月, 2006

PostScript Example

Posted by: asd In: Code Snippet| Script| 程式設計

簡單的 postscript 範例,設定紙張大小,畫線
The three steps we took in drawing our line were:
1. Construct a POSTSCRIPT path, using newpath, moveto, and lineto.
2. stroke that path onto the current page.
3. Print the current page with showpage.
view plain

CODE:

%!

%% Word Graph

 

%PageSize A4

% 若要設定橫印,則設定[842 595]

<</PageSize [595 842]>> setpagedevice

 

newpath

0   4  moveto

194 4  lineto

 

1 setlinewidth

stroke

showpage

寫完後儲存檔案,副檔名為ps,上傳至 ps2pdf,將 ps 轉換到 pdf [...]

Tags:

15 六月, 2006

Upload File

Posted by: asd In: Code Snippet| Script| 程式設計

有時候臨時要傳一個檔案與別人分享,用msn傳嫌太慢,需要一個臨時上傳的空間。網路上有許多免費上傳檔案的空間,若能與檔案總管整合在一起使用,那就很方便。底下的 bat 即是此應用的實現,需搭配 curl 使用 。
view plain

Visual Basic:

@echo off

del tmp.txt 2> nul

setlocal ENABLEDELAYEDEXPANSION

 

:LOOP

if ()==(%1) GOTO END

curl -o 1.htm -F filetoupload=@%1 -F submitted="Upload File" http://mooload.com/new/upload/upload.php

for /f "tokens=1 delims=>"  %%i in ('findstr file.php 1.htm ^| findstr href') do @(

set url1=%%i_

rem echo ORig url1: !url1!

rem echo !url1:~5,-1!

curl -o 2.htm !url1:~5,-1!

for /f "tokens=2 delims==>" %%j in ('findstr Click 2.htm') do @(

set [...]

Tags:

13 六月, 2006

Upload Picture

Posted by: asd In: Code Snippet| Script| 程式設計

有時候臨時要傳一個圖檔給別人看,用msn傳又太慢,需要一個臨時上傳的空間。網路上有許多免費上傳圖檔的空間,若能與檔案總管整合在一起使用,那就很方便。底下的vbs即是此應用的實現,需搭配 curl 使用 。
view plain

Visual Basic:

Set args = WScript.Arguments

Set objShell = CreateObject("WScript.Shell")

Set objFSO   = CreateObject("Scripting.FileSystemObject")

Set fout     = objFSO.OpenTextFile("tmp.txt", 2, True)

 

for k = 0 to args.Count - 1

File = args.Item(k)

Cmd = "%COMSPEC% /c curl.exe  -o tmpp.txt -F uplfile[]=@""%FILE%""  -F upload=upload  http://picsplace.to/index.php"

Cmd = Replace( Cmd,"%FILE%", File )

WScript.Echo Cmd

objShell.Run Cmd,,True

 

'Open the text file

Dim objTextStream, html, nBeg, nEnd

Set objTextStream = [...]

Tags:

11 六月, 2006

Use CDO to Send Mail

Posted by: asd In: Code Snippet| Script| 程式設計

適用win2k、winxp
view plain

Visual Basic:

Const cdoSendUsingMethod        = _

"http://schemas.microsoft.com/cdo/configuration/sendusing"

Const cdoSendUsingPort          = 2

Const cdoSMTPServer             = _

"http://schemas.microsoft.com/cdo/configuration/smtpserver"

Const cdoSMTPServerPort         = _

"http://schemas.microsoft.com/cdo/configuration/smtpserverport"

Const cdoSMTPConnectionTimeout  = _

"http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"

Const cdoSMTPAuthenticate       = _

"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"

Const cdoBasic                  = 1

Const cdoSendUserName           = [...]

Tags:

Page 1 of 212