4 Replies Latest reply: May 10, 2012 9:49 AM by personal_username
personal_username Level 1 Level 1

Hi, is there a way in applescript to read a textfile with one word (es. a serial number) and set it as variable inside the script?

 

I need to upload a file on my ftp, and I'm using the "curl -u" command.

So I have something like this:

 

"curl -u mysitename:mypassword -T /Users/myname/Desktop/filetoupload.txt ftp://ftp.mysitename/SerialNumberAlwaysDifferent/"

 

so, as you get, I'm trying have the applescript dinamically change "SerialNumberAlwaysDifferent" with the string it fetches from a txt.

Any tips?

 

Thanks!

Solved by twtwtw on May 10, 2012 6:35 AM Solved
Use a construction like the following - ampersands are string concatenators, so you can slip the variable text into the string: set serialNumberVariable to read "/path/to/text file.txt"do shell script "curl -u mysitename:mypassword -T /Users/myname/Desktop/filetoupload.txt ftp://ftp.mysitename/" & serialNumberVariable & "/"
Reply by twtwtw on May 10, 2012 9:19 AM Helpful
just tweak what I gave above: set serialNumberVariable to do shell script "system_profiler SPHardwareDataType | sed '/^ *Serial Number (system):*/!d;s###;s/ //'"do shell script "curl -u mysitename:mypassword -T /Users/myname/Desktop/filetoupload.txt ftp://ftp.mysitename/" & serialNumberVariable & "/"

All replies