Applescript to open safari with osescript and specific URL - safari

I am trying to run the following script:
on run proUrl
tell application "Safari"
make new document with properties {URL:proUrl}
end tell
end run
This is how I try to run it: osascript script.scpt http://google.com.
I receive the following error:
script.scpt: execution error: Safari got an error: AppleEvent handler failed. (-10000)
In case I substitue the proUrl variable to "http://google.com" then it works.
How can I fix this?

proUrl is a list of items, even if there's only 1 item you are sending to the applescript. So the actual url is "item 1 of proURL". Here's how I would write your script...
on run proUrlList
open location (item 1 of proUrlList)
end run

To open a URL in your default browser from the command line, just use open:
open http://google.com
See man open for more.

Related

Running and Dump Command Line on VB.net

i am new on VB.Net and dont know the methode for my purpose.
i have application called Monitor.exe running on command line(cmd.exe) with parameter
monitor.exe -o -i
and the output on command line have 3 line like this on success status
status device ready
device running 344 times
complete
or output like this if the process have an error
device error 3
please check the connection cable
My purpose is :
i want run this command line running with ordinary cmd.exe without showing the cmd.exe window with button
then i want to grab the result like "complete 344 times" when the status is complete as label text
or grab "error" word when the status have and error as a label text
your help would be very appriciate.
thanks

Shell Command to launch application with parameters

I am trying to launch spotfire application from VBA like following
Dim retval As Double
retval = Shell("Path\Spotfire.Dxp.exe", vbNormalFocus)
It works. It launches spotfire with the default servername,username and password
But I want to launch the application by giving the servername, username and password as parameters in the script. How do I do it?
I tried this
retval = Shell("Path\Spotfire.Dxp.exe -s http://spotfire.abcd.com -u ABCD\A7 -p ABC", vbNormalFocus)
But it launched the application with default parameters and gives error at the end "Unable to load file. Could not find the specified file : -s"
Please suggest the possible solution.
after checking our support db, I found a few references to / notation instead of -. so the following command should work:
c:\path\Spotfire.Dxp.exe /server:http://localhost:8080/ /username:user /password:pass

PhantomJS Showing exit code 0 even after network error

I am using PhantomJS for printing pdf from my web page and then storing the resultant pdf to S3 if the pdf is generated successfully.
My problem is PhantomJS is returning exit code 0 i.e. success even after a network error occur and the resultant pdf is not which I want.
So I want to know is there any way to abort PhantomJS when error occur with an exit code .
Currently the error in which this happening is NETWORK Error : 101
But even though PhantomJS do not abort and return with exit code 0
The only time that PhantomJS exits on its own is when it encounters a Syntax Error of your script (PhantomJS 2.0.0 has a bug and simply freezes and doesn't print anything at this point).
For everything else you need to call phantom.exit() to exit. phantom.exit() takes an optional argument which is the exit code. So when you encounter an error for example by checking the success argument of the page.open() callback or when onResourceError or onResourceTimeout events are triggered, you can exit PhantomJS with your own intended exit code such as
phantom.exit(1);

How to write a ping to a text file using VBS

If I am using VBS to run some CMD commands, in this example ping, how could I write the command to a text file using VBS not DOS?
Set objCmdTest = WScript.CreateObject ("WScript.Shell")
Set Output = CreateObject("Scripting.FileSystemObject").OpenTextFile("C:\vbs\test.txt",8,true)
Output.WriteLine (objCmdTest.run ("ping failboat"))
Output.WriteLine (objCmdTest.run ("ping 8.8.8.8"))
So this is what I'm working with however what happens is; The script runs, the file is made, 2 command prompts open to run the pings and finally the text inside the file reads:
0
0
When I'd much prefer it to have the ping output.
FYI: Please don't offer suggestions that require me to use DOS for the writing, I'd like to see how VBS can do what I need for multiple reasons, thanks!
The instruction Output.WriteLine (objCmdTest.run ("ping failboat")) will write the return value of the Run method to the output file. If you want to append the command output to an output file you have to either redirect the output in the command:
objCmdTest.run "%COMSPEC% /c ping failboat >>C:\vbs\test.txt", 0, True
or use Exec instead of Run:
Set ping = objCmdTest.Exec("ping failboat")
Do While ping.Status = 0
WScript.Sleep 100
Loop
Output.WriteLine ping.StdOut.ReadAll
WScript.Shell's run method returns the process's exit code. In order to get access to an application's output, you need to use the exec method instead, and use the object that returns to get access to the process's standard output through its StdOut property.

hide error messages in dcl script

I have a test script I'm running that generates some errors,shown below, I expect these errors. Is there anyway I can prevent them from showing on the screen however? I use the
$ write sys$output
to display if there is an expected error.
I tried to use
$ DEFINE SYS$ERROR ERROR.LOG
but this then changed my entire error output log to this, if this is the correct way to handle it can I unset this at the end of my script somehow?
[error example]
%DCL-E-OPENIN, error opening TEST$DISK:[AAA]NOTTHERE.TXT; as input
-RMS-E-FNF, file not found
%DCL-E-OPENIN, error opening TEST$DISK:[AAA]NOTTHERE.TXT; as input
-RMS-E-FNF, file not found
%DCL-W-UNDFIL, file has not been opened by DCL - check logical name
DEFINE/USER creates a logical name that disappears when the next image exits.
So if you use that just before a command just to protect that command, then fine.
Otherwise I would prefer SET MESSAGE to control the output.
And of course yoy want to grab $STATUS and verify it after the command for success or for the expected error, reporting any unexpected error.
Better still... if you expect certain error conditions to occur,
then why not test for them?
For example:
$ file = F$SEARCH("TEST$DISK:[AAA]NOTTHERE.TXT")
$ IF file.NES."" THEN TYPE 'file'
Cheers,
Hein
To suppress Error message inside a script. try this command
$ DEFINE/USER SYS$ERROR NL:
NL: is a null device, so you don`t see any error messages displayed on your terminal.
good luck
This works interactively and in batch.
$ SET MESSAGE /NOTEXT /NOSEV /NOFAC /NOID
$ <DCL_Command>
$ SET MESSAGE /TEXT /SEV /FAC/ ID