w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Pass Argument to -FilePath in Powershell
This works on PowerShell v3. Are you on V2? 9# gc .foo.ps1 param($myarg) hostname "parameter value of myarg is $myarg" 10# $filename = "c:foo.txt" 11# Invoke-Command Beagle2 -FilePath .foo.ps1 -ArgumentList $filename BEAGLE2 parameter value of myarg is c:foo.txt BTW, foo.ps1 doesn't exist on the remote computer. It is being transported by PowerShell to the remote computer for execution. Now if $filename contains a local computer path, I'm not sure how that would work on the remote computer unless it points to a file that is common to both computers.

Categories : Dotnet

Using subprocess to run an executable with a flag
You're using backslashes in your strings. If you don't escape them, it will try to interpret the backslashes as escape characters. For example, your un-escaped string: >>> 'datafile.txt' '\datax0cile.txt' Notice that f gets turned into a different character. That's because if you look at the table of escape characters you will see that f maps to the ASCII Formfeed (FF) character. You'll want to either escape them: >>> '\data\file.txt' '\data\file.txt' or use a literal string: >>> r'datafile.txt' '\data\file.txt' For example, here's an attempt to rewrite your Run function: import subprocess import time def Run(path='\data\file.txt'): flag = '-f%s' % path subprocess.call(['C:\folder\program', flag]) You should always use an absolute path when calli

Categories : Python

How to distinguish between empty argument and zero-value argument in Powershell?
You can just test $args variable or $args.count to see how many vars are passed to the script. Another thing $args[0] -eq $null is different from $args[0] -eq 0 and from !$args[0].

Categories : Powershell

How to send an argument from one python script to another using subprocess.Popen communicate?
When you do: process.communicate(f) you are writing to the standard input of process; the problem is that the latter program must read the data from its input stream in order to make use of it. You could change file2.py to something like: import sys def c(x): print x for f in sys.stdin: c(f) You seem to be thinking that communicate() allows the parent and child processes to share variable bindings; that's not the case. As written in your question, file2.py would generate an error to the effect that name 'f' is not defined.

Categories : Python

How to pass utf8 strings properly from python to hunspell via subprocess.Popen?
As Iwan Aucamp suggested in the comments, the solution is to use: hunspell -i UTF-8 ... i.e. make sure that hunspell knows it's getting UTF-8 strings. Once I added that to my code, the results I was getting in the shell (even without the -i flag) and the results I was getting by piping strings to hunspell from Python were the same.

Categories : Python

Powershell Start-Process to start Powershell session and pass local variables
I'm pretty sure there's no direct way to pass variables from one PowerShell session to another. The best you can do is some workaround, like declaring the variables in the code you pass in -ArgumentList, interpolating the values in the calling session. How you interpolate the variables into the declarations in -ArgumentList depends on what types of variables. For an array and a string you could do something like this: $command = '<contents of your scriptblock without the curly braces>' Start-Process powershell -ArgumentList ("`$Array = echo $Array; `$String = '$String';" + $command)

Categories : Powershell

Powershell and dollar sign in argument
The easy way is to enclose it in single quotes. For ex.: .myDollarParam.ps1 -Password 'Pa$sword' Otherwise PowerShell interprets the "$" as the start of a variable, so what you are basically saying in your example, is assign the variable the value "Pa" and then the value stored in the variable "$sword" A to prove this theory running the following gives me the interesting result: $sword = "Stuff" .myDollarParam.ps1 -Password Pa$sword PaStuff By enclosing in single quotes, you are saying pass the literal characters in this string. The "proper" way to do passwords is to use the ConvertTo-SecureString cmdlt.

Categories : Windows

Getting error "The user instance login flag is not supported on this version of SQL Server." but not using this flag
This code uses ASP.NET Membership Roles Provider if (filterContext.HttpContext.User.IsInRole(r.Trim())) The machine.config shows <roleManager> <providers> <add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> <add name="AspNetWindowsTokenRoleProvider" applicationName="/" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> </providers> </roleManager> Pointing to "LocalSqlServer" in the same file <connectionStrings> <add n

Categories : Sql Server

Although flag is already set - Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag
Well, this code is cropped, I can´t see all I need, but what I can see is that You have to set this before calling startActivity(i); Intent i = new Intent(this, DataCountUtilities.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i);

Categories : Java

Can't pass char*** as argument
Here you overwrite the pointer to your char** fileList, which might be one problem: fileList = malloc(sizeof(char***)); Here you overwrite a previously allocated pointer, which looks like another problem: *fileList = malloc(*noOfFiles * sizeof(char*));

Categories : C

Can't pass more than one argument using exec() PHP
Try to use escapeshellarg to make sure your arguments are properly escaped It appears also based on this post that php will frame the argument passed to exec with cmd /c "{{exec argument}}" when passing it off to the shell. Try this: exec('c:wampwwwTelnetshutdown.py '.escapeshellarg($router).' '.escapeshellarg($interface));

Categories : PHP

Is there a way to pass an argument to the is operator?
I think you're looking for Type.IsAssignableFrom: public bool IsOfType(Type type) { return _item != null && type.IsAssignableFrom(_item.GetType()); } Or if you can make the method generic, that's simpler as you can use is with a type parameter: public bool IsOfType<T>() { return _item is T; } EDIT: As noted in Wim's answer, there's also Type.IsInstanceOf which makes the non-generic method simpler: public bool IsOfType(Type type) { return type.InstanceOf(_item); }

Categories : C#

How to pass function as an argument?
Use a function_handle: function R = GetY(func,x) R = func(x); end ... >> GetY(@sin, pi/2) ans = 1 >> >> GetY(@(x) x.^2 + 4, 2) ans = 8

Categories : Matlab

What is the best way to pass an argument into a Func<> in C#?
Your buildings delegate will need to be a Func<T, TResult> instead of a Func<TResult>. Assuming cityId is an int: public void Test(Request request, Func<int, IEnumerable<Building>> buildings) { var cityId = GetCity(); m.Buildings = Helper.GenerateDropdownList(request.BuildingId, () => buildings(cityId)); }

Categories : C#

How to pass "nothing" as an argument to `[` for subsetting?
After some poking around, alist seems to do the trick: x <- matrix(1:6, nrow=3) x [,1] [,2] [1,] 1 4 [2,] 2 5 [3,] 3 6 # 1st row do.call(`[`, alist(x, 1, )) [1] 1 4 # 2nd column do.call(`[`, alist(x, , 2)) [1] 4 5 6 From ?alist: ‘alist’ handles its arguments as if they described function arguments. So the values are not evaluated, and tagged arguments with no value are allowed whereas ‘list’ simply ignores them. ‘alist’ is most often used in conjunction with ‘formals’. A way of dynamically selecting which dimension is extracted. To create the initial alist of the desired length, see here (Hadley, using bquote) or here (using alist). m <- array(1:24, c(2,3,4)) ndims <- 3 a <- rep(alist(,)[1], ndims) for(i in seq_len(n

Categories : R

C# pass path in argument
You need to put the file path in double quotes and use a verbatim string literal (@) as SLaks mentioned. CommandStart.StartInfo.Arguments = @"""C:MyPathfile.exe"" -arg bla -anotherArg"; Example with an OpenFileDialog using(OpenFileDialog ofd = new OpenFileDialog()) { if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string filePath = """ + ofd.FileName + """; //..set up process.. CommandStart.StartInfo.Arguments = filePath + " -arg bla -anotherArg"; } } Update to comment You can format your string using String.Format. string finalPath = String.Format(""{0}{1}_date_{2}.sql"", AppDomain.CurrentDomain.BaseDirectory, SQLActions.MySQLDatabase, date); Then pass finalPath into the arguments.

Categories : C#

How to pass the id of Div as an argument to a function
In my opinion, you'd be better of if you created actual elements instead of a string. It's more stuff to write, but makes everyhing a lot easier to keep track of : var input_append = $('<div />', {id: 'artist' + (artists.length - 1)}), label = $('<label />', {style: 'background-color:#e0ffff', text : artistVal } ), image = $('<img />', {id: 'removeartist', src: '/Content/bootstrap/img/cross-button.png', on: { click: function() { input_append.remove(); artists.splice(artists.l

Categories : Javascript

Pass C# Variables to Powershell Engine
When you call the AddParameter overload that takes two parameters, the second one is the value. Just use the name of the C# variable there e.g.: string mailbox = _mailBoxTextBox.Text; ... powershell.AddParameter("Mailbox", mailbox);

Categories : C#

Why can't C function pass right argument to java?
long in Java is always a 64-bit integer type, long in C may be a 32-bit integer type (at least on x86 32 bits linux). So they are different. That's why you get garbage. In C, use jlong instead of long, which is typedefed to a sufficiently long integer datatype.

Categories : Java

Pass the 'container' as an argument to service
The container is registered as the service called "service_container", so you must pass "service_container" and not just "container": <argument type="service" id="service_container" /> This is why currently Symfony doesn't understand what is the service "container" because there is no one registered with this name !

Categories : Symfony2

Progress bar pass float argument
setProgress() doesn't have float argument. So you can not set float value. but you can cast your float value to int by- pb.setProgress((int)mypb);

Categories : Android

DOM pass argument to javascript function
If I understand your question correctly, the problem is that you're not accepting the event argument in the main handler. E.g., in your first example: b.onkeypress = function() { on(event); }; it should be b.onkeypress = function(e) { on(e || window.event); }; // Changes here --------^ and --^^^^^^^^^^^^ You're doing that in on, but in on, it's already too late, you've lost the argument provided to the onXYZ function. The reason your code works in Chrome and IE is that IE uses a global event object instead of (or in modern versions, in addition to) the one it actually passes into the handler, and Chrome replicates that behavior for maximum compatibility with websites that expect that. Firefox does not.

Categories : Javascript

Pass a parent class as an argument?
Have you tried something like this? class SomeParentClass(object): # ... pass def Child(parent): class Child(parent): # ... pass return Child() instance = Child(SomeParentClass) In Python 2.x, also be sure to include object as the parent class's superclass, to use new-style classes.

Categories : Python

How to pass argument to Context in android
Use of Context: You can get the context by invoking getApplicationContext(), getContext(), getBaseContext() or this (when in the activity class). Creating New objects: Creating new views, adapters, listeners: TextView text = new TextView(getContext()); ListAdapter adapter = new SimpleCursorAdapter(getApplicationContext(), ...); Accessing Standard Common Resources: Services like LAYOUT_INFLATER_SERVICE, SharedPreferences: context.getSystemService(LAYOUT_INFLATER_SERVICE) getApplicationContext().getSharedPreferences(name, mode); Accessing Components Implicitly: Regarding content providers, broadcasts, intent getApplicationContext().getContentResolver().query(uri, ...);

Categories : Android

Pass website url as an argument in htaccess
Untested but should work, give it a go: RewriteCond %{HTTP_HOST} ^(www.example1.com)$ RewriteRule $^ http://www.adminwebsite.com/index.php?website=%1 [R=302,L] Keep in mind that if your adminwebsite domain is not the default domain of the server you will still need to configure the example1 domain on the HTTP server otherwise it won't work or if you have cPanel you will have to create an addon with it.

Categories : Htaccess

Variable won't pass over as an argument in AngularJS
Try removing the {{}} in your function call. They aren't required. Not sure why it would still find some of the vars and not others, but in my plunker when I removed them, things started working.

Categories : Forms

how to pass argument to Marionette.CompositeView
at the moment you instanciate a view, you can pass whatever arguments you want. normally you pass the model and the collection to be rendered in the compositeView, but you can pass more data if you need. var MyCompositeView = Backbone.Mationette.CompositeView.extend({ initialize : function (options){ this.dataValue = options.dataValue1; this.helperObject = options.helperObject; this.useValues(); }, useValues: function () { console.log(this.dataValue); } }); var helperObject = { value3 : "I have a value", value4 : "I dont!" }; /// a js object literal var myModel = new MyModel(); var myCollection = new MyCollection(); var myCompositeView = new MyCompositeView({model:myModel, c

Categories : HTML

Is it possible to pass an OrderBy expression as an argument?
The lambda expression is just a function. So you should be able to use Func<IEnumerable<TEntity>,IEnumerable<TEntity>>. You are effectivly wanting to pass in a function that takes in an IEnumerable and give out a different IEnumerable.

Categories : C#

Is it possible to pass function in using keyword argument
You don't really need macros to do this. Ruby has a pretty dynamic runtime, so just do it using the message passing semantics that OO design involves and use #send. def binary_cmp (a, b, test_func = :>) a.send(test_func, b) end binary_cmp(42, 7, :<) # => false

Categories : Ruby

Can't pass $this as an argument to an object constructor
$this->$func_helper should be $this->func_helper. You don't need the extra $ in front of property names. I personally think this is very inconsistent syntax, but it is how it is. :( The error you are getting, is because PHP is searching for a local variable named $func_helper. It wants to use the value of that variable to find a property name of $this. So actually you're not yet writing the property but reading the local variable, which doesn't exist. therefor, you get this error.

Categories : PHP

Pass argument to log4j file
Sample properties in log4j.properties log4j.appender.file.File=${LOG_FILE_PATH}/${LOG_FILE_NAME} Bear in mind that log4j will try to find log4j.properties and load automatically when initialised. Therefore, I can only think of passing the argument as JVM arguments. In VM Arguments: -DLOG_FILE_PATH=C:log -DLOG_FILE_NAME=apps.log

Categories : Java

Pass in string as argument without it being treated as raw
The string you receive in sys.argv[1] is exactly what you typed on the command line. Its backslash sequences are left intact, not interpreted. To interpret them, follow this answer: basically use .decode('string_escape').

Categories : Python

Ajax doesn't pass the argument
Try to use POST instead of GET: the GET has limit on browsers for example IE has max length 2,083 characters don't use GET for big data.

Categories : Javascript

Want to pass an argument to my shell function
Modify your grep line like this: grep -rni "^$test" include Update: grep -rni "^$test" include actually becomes: grep -rni "^struct task_struct" include However, grep -rni '^'$test' ' include gets interpreted as: grep -rni ^struct task_struct include If you notice above, the search pattern for grep is only ^struct, whereas task_struct is considered as one of the files to search for the pattern along with include and hence the issue you faced where it was considering only struct not the whole thing. Its mandatory to double quote whenever its a multi-worded string.

Categories : Bash

c++ could not pass argument to std::priority_queue constructor
You have been a victim of C++'s Most Vexing Parse. Instead of doing std::priority_queue<std::shared_ptr<int>, std::vector<std::shared_ptr<int>>, Compare1> myq(Compare1()); std::priority_queue<std::shared_ptr<int>, std::vector<std::shared_ptr<int>>, Compare1> myq(Compare1(false)); enclose in parentheses the constructor parameters std::priority_queue<std::shared_ptr<int>, std::vector<std::shared_ptr<int>>, Compare1> myq((Compare1())); // ^ ^ std::priority_queue<std::shared_ptr<int>, std::vector<std::shared_ptr<int>>, Compare1> myq((Compare1(false))); //

Categories : C++

How to: Pass Arguments to Python Script via Powershell
Got it! Darn single quotes..... $env:Path += ";c:Program Fileslcpython15"; $env:PATHEXT += ";.py"; $arg1 = "Test3" $arg2 = "Testing" $arg3 = 'c:ProgramDataset_cust_attr.py' python $arg3 $arg1 $arg2

Categories : Python

Pass a function (with arguments) as a parameter in PowerShell
Don't you want to do something like this? function Add([int] $x, [int] $y) { return $x + $y } function Apply([scriptblock] $s) { Write-Host $s.Invoke($args) } Apply { Add 1 2}

Categories : Powershell

How to pass a variable in the select-string of powershell
Works fine here. Try specifying the paramters to make sure the right value is assigned to the right parameter. $match2 = Select-String -SimpleMatch -Pattern $match1 -Path . est.txt

Categories : Windows

Can I pass a VBA variable into a called Powershell script?
You just need to define parameters at the top of your script: param([string]$path) $content = [IO.File]::ReadAllText($path) # etc. In VBA, you need to pass the parameter: Shell("powershell.exe -ExecutionPolicy Unrestricted -File <pathname>Convert_To_Tab_Delimited.ps1 -path """ & pathVariable & """", 1)

Categories : Powershell

Pass argument to bash script with expect and SSH
instead of passing simulating an interactive session i would: setup ssh key based authentication - this removes the need of entering the password then use: ssh root@kroute "logread | grep asd"

Categories : Bash



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.