Mombu the Programming Forum

Go Back   Mombu the Programming Forum > Programming > Unable to pass data to applescript from data file through terminal
User Name
Password
REGISTER NOW! Mark Forums Read




Reply
1 25th September 09:33
External User
 
Posts: 1
Default Unable to pass data to applescript from data file through terminal



Hello All,
I am facing the problem regarding sending data to from data file ( CSV
file ) to applescript on terminal.
I have used :
$ osascript <applescript Name > <Data file Name >
under apple script I used : "run" command
llike :
on run argv
set <Veriable Name > to item 1 of argv

-----
---
end run

When I run this script on Terminal it gives me error : End of file
error (-39)
Please provide your valuable inputs to get the data file file from
command prompt .
If I hard code the data file in the applescript , it works :
Example:
set <Variable Name > to "Path of file"

Thanks !!!
  Reply With Quote


 


2 25th September 09:33
jolly roger
External User
 
Posts: 1
Default Unable to pass data to applescript from data file through terminal



In article
<379391e5-a5c2-4d60-9cf2-5254986d92ac@i29g2000prf.googlegroups.com>,


Without seeing the *actual* script, it's hard to know what you are doing
wrong.

This works fine here:

-- begin script
on run argv
set x to item 1 of argv
return x
end run
-- end script

In a terminal window:

# osascript test.scpt 'this is a test'
Argument: this is a test

--
Note: Please send all responses to the relevant news group. E-mail
sent to this address may be devoured by my very hungry SPAM filter.

JR
  Reply With Quote


 


3 25th September 09:33
External User
 
Posts: 1
Default Unable to pass data to applescript from data file throughterminal


Deepak Jain wrote:
content of file :
-----------------------------------------------------------------------------
on run argv
set CSV to "& item 1 of argv &"
set afile to open for access CSV
set alllines to read afile using delimiter {return}
close access afile
set a_veriables to {}
repeat with aline in alllines
set oldtids to the text item delimiters
set the text item delimiters to {","}
set list_of_variables to every text item of aline
set the text item delimiters to oldtids
set t1 to item 1 of list_of_variables
set t2 to item 2 of list_of_variables
set t3 to item 3 of list_of_variables
set t4 to item 4 of list_of_variables
--set end of a_veriables to {var1:t1, var2:t2, var3:t3,var:t4}
end repeat
tell application "iCal"
tell calendar "dj"
make new event at end with properties {description:t3, summary:t1,
location:t2, recurrence:t4}
end tell
end tell
end run
-----------------------------------------------------
And csv file which contains 2 rows of data.
  Reply With Quote
4 25th September 09:33
External User
 
Posts: 1
Default Unable to pass data to applescript from data file throughterminal


Got the way ...........
thanks :-)
  Reply With Quote
Reply


Thread Tools
Display Modes




666