Search Results

Search found 33 results on 2 pages for 'backticks'.

Page 1/2 | 1 2  | Next Page >

  • Equivalent of Backticks in Python

    - by Chris Bunch
    What is the equivalent of the backticks found in Ruby and Perl in Python? That is, in Ruby I can do this: foo = `cat /tmp/baz` What does the equivalent statement look like in Python? I've tried os.system("cat /tmp/baz") but that puts the result to standard out and returns to me the error code of that operation.

    Read the article

  • Unix: How to use Bash backticks recursively

    - by HH
    Either I missed some backlash or backlashing does not seem to work with too much programmer-quote-looping. $ echo "hello1-`echo hello2-\`echo hello3-\`echo hello4\`\``" hello1-hello2-hello3-echo hello4 Wanted hello1-hello2-hello3-hello4-hello5-hello6-...

    Read the article

  • Batch equivilant of Bash backticks

    - by MiffTheFox
    When working with Bash, I can put the output of one command into another command like so: my_command `echo Test` would be the same thing as my_command Test (Obviously, this is just a non-practical example.) I'm just wondering if you can do the same thing in Batch.

    Read the article

  • php:: apply backticks to first word in sentence

    - by Hailwood
    Hi guys, basically what I am trying to do is, I have an array that looks something like this: array( array( 'select' =>'first string', 'escape' => true ), array( 'select' =>'second', 'escape' => true ), array( 'select' =>'the third string', 'escape' => true ), array( 'select' =>'fourth string', 'escape' => false ), ) I am looping over it and I want to end up with this output array( array( 'select' =>'`first` string', 'escape' => true ), array( 'select' =>'`second`', 'escape' => true ), array( 'select' =>'`the` third string', 'escape' => true ), array( 'select' =>'fourth string', 'escape' => false ), ) so basic rules are backticks are only applied if escape is true backticks are only applied to the first word in a sentence if there is only one word backticks are applied to the word My plan was to use if($item['escape']) { $pos = (strpos($item['select'], ' ') === false ? strlen($item['select']) : strpos($item['select'], ' ')); $item['select'] = '`' . substr($item['select'], 0, $pos) . '`' . substr($item['select'], $pos, strlen($item['select'])); } but the $item['select'] = line seems rather long winded, is there a better way to write it?

    Read the article

  • eventmachine and external scripts via backticks

    - by Maciek
    I have a small HTTP server script I've written using eventmachine which needs to call external scripts/commands and does so via backticks (``). When serving up requests which don't run backticked code, everything is fine, however, as soon as my EM code executes any backticked external script, it stops serving requests and stops executing in general. I noticed eventmachine seems to be sensitive to sub-processes and/or threads, and appears to have the popen method for this purpose, but EM's source warns that this method doesn't work under Windows. Many of the machines running this script are running Windows, so I can't use popen. Am I out of luck here? Is there a safe way to run an external command from an eventmachine script under Windows? Is there any way I could fire off some commands to be run externally without blocking EM's execution? edit: the culprit that seems to be screwing up EM the most is my usage of the Windows start command, as in: start java myclass. The reason I'm using start is because I want those external scripts to start running and keep running after the EM request is served

    Read the article

  • protobuf-net - backticks, Dictionaries & .proto files

    - by JosephH
    I'm trying to talk to a C# program that uses protobuf-net from an iphone using http://code.google.com/p/metasyntactic/wiki/ProtocolBuffers Unfortunately the .proto file I've been given (generated from the C# source code) includes an a line that protoc is rejecting: repeated Pair_Guid_List`1 Local = 6; It appears that this is because the source data is a C# Dictionary, with a Guid key and a class as the value. Is there a way to cope with this better? The protobuf-net version in use is r278.zip. (The C# sending and receiving these protobufs all works fine, it's just when we add the iphone into the mix that this becomes an issue.)

    Read the article

  • PHP Path issue running backticks/exec()

    - by Lee
    Hey all I'm trying to run a java jar file from the command line and within the the execution it gives a path. Withing this path their are spaces and this is causing the issue. ie $f = `java -jar /OCR/ocr.jar /Folder/Sub Folder/filetoocr.pdf /ocr/output.txt`; echo "<pre>$output</pre>"; If you can see the space in between the Sub Folder name causes the issue. By command line it would be (which works) java -jar /OCR/ocr.jar /Folder/Sub\ Folder/filetoocr.pdf /ocr/output.txt any suggestions how I can resolve this ?? Hope you can advise

    Read the article

  • MySQL grouping by a previously declared alias, what do I wrap it in? ' OR `

    - by cgmojoco
    I have an SQL query that has an alias in the SELECT statement SELECT CONCAT(YEAR(r.Date),_utf8'-',_utf8'Q',QUARTER(r.Date)) AS 'QuarterYear' Later, I want to refer to this in my group by statement. I'm a little confused...should I wrap this with backticks, single quote or just leave it unwrapped int he group by GROUP BY `QuarterYear ` or should I do this?: GROUP BY 'QuarterYear' or just this?: GROUP BY QuarterYear

    Read the article

  • Perl regex matching output from `w -hs` command

    - by Bushman
    I'm trying to write a Perl script that will work better with KDE's kwrited, which, as far as I can tell, is connected to a pts and puts every line it receives through the KDE system tray notifications, with the title "KDE write daemon". Unfortunately, it makes a separate notification for each and every line, so it spams up the system tray with multiline messages on regular old write, and for some reason it cuts off the entire last line of the message when using wall (One-line messages are also goners.). I was also hoping to make it so that it could broadcast across a LAN with thick clients. Before starting on that (which would require ssh, of course), I tried to make an ssh-less version to make sure it works. Unfortunately, it doesn't. perl ./write.pl "Testing 1 2 3" where the following is the contents of ./write.pl: #!/usr/bin/perl use strict; use warnings; my $message = ""; my $device = ""; my $possibledevice = '`w -hs | grep "/usr/bin/kwrited"`'; #Where is kwrited? $possibledevice =~ s/^[^\t][\t]//; $possibledevice =~ s/[\t][^\t][\t ]\/usr\/bin\/kwrited$//; $possibledevice = '/dev/'.$possibledevice; unless ($possibledevice eq "") { $device = $possibledevice; } if ($ARGV[0] ne "") { $message = $ARGV[0]; $device = $ARGV[1]; } else { $device = $ARGV[0] unless $ARGV[0] eq ""; while (<STDIN>) { chomp; $message .= <STDIN>; } } if ($message ne "") { system "echo \'$message\' > $device"; } else { print "Error: empty message" } produces the following error: $ perl write.pl "Testing 1 2 3" Use of uninitialized value $device in concatenation (.) or string at write.pl line 29. sh: -c: line 0: syntax error near unexpected token `newline' sh: -c: line 0: `echo 'foo' > ' Somehow, the regular expressions and/or the backtick escape in processing $possibledevice are not working properly, because where kwrited is connected to /dev/pts/0, the following works perfectly: $ perl write.pl "Testing 1 2 3" /dev/pts/0

    Read the article

  • Types of quotes for an HTML templating language

    - by Ralph
    I'm developing a templating language, and now I'm trying to decide on what I should do with quotes. I'm thinking about having 3 different types of quotes which are all handled differently: backtick ` double quote " single quote ' expand variables ? yes no escape sequences no yes ? escape html no yes yes Backticks Backticks are meant to be used for outputting JavaScript or unescaped HTML. It's often handy to be able to pass variables into JS, but it could also cause issues with things being treated as variables that shouldn't. My variables are PHP-style ($var) so I'm thinking that might mess with jQuery pretty bad... but if I disable variable expansion w/ backticks then, I'm not sure how would insert a variable into a JS code block? Single Quotes Not sure if escape sequences like \n should be treated as literals or converted. I find it pretty rare that I want to disable escape sequences, but if you do, you could use backticks. So I'm leaning towards "yes" for this one, but that would be contrary to how PHP does it. Double Quotes Pretty certain I want everything enabled for this one. Modifiers I'm also thinking about adding modifiers like @ or r in front of the string that would change some of these options to enable a few more combinations. I would need 9 different quotes or 3 quotes and 2 modifiers to get every combination wouldn't I? My language also supports "filters" which can be applied against any "term" (number, variable, string) so you could always write something like "blah blah $var blah"|expandvars Or "my string"|escapehtml Thoughts? What would you prefer? What would be least confusing/most intuitive?

    Read the article

  • Text Parsing - My Parser Skipping commands

    - by The.Anti.9
    I'm trying to parse text-formatting. I want to mark inline code, much like SO does, with backticks (`). The rule is supposed to be that if you want to use a backtick inside of an inline code element, You should use double backticks around the inline code. like this: `` mark inline code with backticks ( ` ) `` My parser seems to skip over the double backticks completely for some reason. Heres the code for the function that does the inline code parsing: private string ParseInlineCode(string input) { for (int i = 0; i < input.Length; i++) { if (input[i] == '`' && input[i - 1] != '\\') { if (input[i + 1] == '`') { string str = ReadToCharacter('`', i + 2, input); while (input[i + str.Length + 2] != '`') { str += ReadToCharacter('`', i + str.Length + 3, input); } string tbr = "``" + str + "``"; str = str.Replace("&", "&amp;"); str = str.Replace("<", "&lt;"); str = str.Replace(">", "&gt;"); input = input.Replace(tbr, "<code>" + str + "</code>"); i += str.Length + 13; } else { string str = ReadToCharacter('`', i + 1, input); input = input.Replace("`" + str + "`", "<code>" + str + "</code>"); i += str.Length + 13; } } } return input; } If I use single backticks around something, it wraps it in the <code> tags correctly.

    Read the article

  • Trying to execute netdom.exe from a ruby script or IRB does nothing

    - by Joraff
    I'm trying to write a script that will rename a computer and join it to a domain, and was planning to call on netdom.exe to do the dirty work. However, trying to run this utility in the script (same results in irb) does absolutely nothing. No output, no execution. I tried with backticks and with the system() method. System() returns false for everything but system("netdom") (which returns true). Backticks never return anything but an empty string. I have verified that netdom runs and works in the environment the script will be running in, and I'm calling other command-line utilities earlier in the script that work (w32tm, getmac, ping). Here's the exact line that gets executed: `netdom renamecomputer %COMPUTERNAME% /NewName:#{newname} /force` FYI, This is windows 7 x64

    Read the article

  • How can I unit test a PHP class method that executes a command-line program?

    - by acoulton
    For a PHP application I'm developing, I need to read the current git revision SHA which of course I can get easily by using shell_exec or backticks to execute the git command line client. I have obviously put this call into a method of its very own, so that I can easily isolate and mock this for the rest of my unit tests. So my class looks a bit like this: class Task_Bundle { public function execute() { // Do things $revision = $this->git_sha(); // Do more things } protected function git_sha() { return `git rev-parse --short HEAD`; } } Of course, although I can test most of the class by mocking git_sha, I'm struggling to see how to test the actual git_sha() method because I don't see a way to create a known state for it. I don't think there's any real value in a unit test that also calls git rev-parse to compare the results? I was wondering about at least asserting that the command had been run, but I can't see any way to get a history of shell commands executed by PHP - even if I specify that PHP should use BASH rather than SH the history list comes up empty, I presume because the separate backticks executions are separate terminal sessions. I'd love to hear any suggestions for how I might test this, or is it OK to just leave that method untested and be careful with it when the app is being maintained in future?

    Read the article

  • DBMS agnostic - What to name the COUNT column from a SQL Query

    - by cyberkiwi
    I have trouble naming the COUNT() column from SQL queries and will swap between various variants _Count [Count] (sql, or "count" or backticks for MySQL etc) C Cnt CountSomething (where "something" is the field being counted, or "CountAll") NoOfRows RowCount etc Has anyone come up with any name that you are happy with and always use without hesitation? This is bothering me because after joining SO just recently, my answers have shown this tendency of flip-flopping with no consistency. I need to get this sorted. Please help. (While we're at it, what do you use for SUM etc?) Note: Before you close this question, consider that this one was not: What's the best name for a non-mutating “add” method on an immutable collection?

    Read the article

  • Invoking shell commands from Squeak or Pharo

    - by squeaknewb
    How can you invoke shell commands from Squeak and Pharo? Do these environments have anything in them like the system() function in certain unix languages to run external shell commands, or the backticks (can't make them here do to the editor, but what you get when you push the key left of "1" and above "TAB") to capture the output of commands?

    Read the article

  • how to ssh in perl script

    - by Salman
    Hi I want to SSH to a server and execute a simple command like "id" and get the output of it and store it to a file on my primary server. I do not privileges to install Net::SSH which would make my task very easy. please provide me a solution for this. I tried using backticks but I am not able to store the output on the machine from which my script runs.

    Read the article

  • Zsh command substitution

    - by Dr. Watson
    I usually work with BASH, but I'm trying to setup a cronjob from a machine and user account that is configured with zsh. When the cronjob runs, the date variable does not contain the date, just the string for the command to return the date. DATE=$(date +%Y%m%d) 55 15 * * 1-5 scp user@host:/path/to/some/file/$DATE.log /tmp I've tried using backticks rather than $() around the command, but that did not work either. Is there a special way to do command substitution in zsh?

    Read the article

  • How can I ssh inside a Perl script?

    - by Salman
    I want to SSH to a server and execute a simple command like "id" and get the output of it and store it to a file on my primary server. I do not privileges to install Net::SSH which would make my task very easy. Please provide me a solution for this. I tried using backticks but I am not able to store the output on the machine from which my script runs.

    Read the article

  • MySQL Federated Tables Escaped Table Names

    - by Gordon
    I am trying to use MySQL federated tables. The problem is that the documentation specified at http://dev.mysql.com/doc/refman/5.0/en/federated-use.html says that a federated table should be created using the following format for the CONNECTION parameter: scheme://user_name[:password]@host_name[:port_num]/db_name/tbl_name E.G. CONNECTION='mysql://username:password@hostname:port/database/tablename' CONNECTION='mysql://username@hostname/database/tablename' CONNECTION='mysql://username:password@hostname/database/tablename' The problem is that the table I am trying to connect to has non-standard characters in it and I cannot find the proper way to scape them in the connections tring. For example, a table named `Table (one)` . Which has the space and the parenthesis, requiring backticks surrounding it inside any SQL code. Anyone know the proper way to do this?

    Read the article

  • How can I tell what Apache modules are available to me?

    - by AgentConundrum
    I'm currently reading 'Definitive Guide to Apache mod_rewrite' and throughout the book there are other Apache modules mentioned that are better alternatives in given scenarios. This has got me wondering what all is installed on my site. I don't have SSH access to the server, and I don't have access to any of the config files (afaik). Is there any way for me to determine what is installed, or do I have to directly ask my host? I suppose certain commands could be run inside PHP (i.e. using backticks), but I'm not sure what the limitations of that are. Thanks.

    Read the article

  • Calling system commands from Perl

    - by Dan J
    In an older version of our code, we called out from Perl to do an LDAP search as follows: # Pass the base DN in via the ldapsearch-specific environment variable # (rather than as the "-b" paramater) to avoid problems of shell # interpretation of special characters in the DN. $ENV{LDAP_BASEDN} = $ldn; $lcmd = "ldapsearch -x -T -1 -h $gLdapServer" . <snip> " > $lworkfile 2>&1"; system($lcmd); if (($? != 0) || (! -e "$lworkfile")) { # Handle the error } The code above would result in a successful LDAP search, and the output of that search would be in the file $lworkfile. Unfortunately, we recently reconfigured openldap on this server so that a "BASE DC=" is specified in /etc/openldap/ldap.conf and /etc/ldap.conf. That change seems to mean ldapsearch ignores the LDAP_BASEDN environment variable, and so my ldapsearch fails. I've tried a couple of different fixes but without success so far: (1) I tried going back to using the "-b" argument to ldapsearch, but escaping the shell metacharacters. I started writing the escaping code: my $ldn_escaped = $ldn; $ldn_escaped =~ s/\/\\/g; $ldn_escaped =~ s/`/\`/g; $ldn_escaped =~ s/$/\$/g; $ldn_escaped =~ s/"/\"/g; That threw up some Perl errors because I haven't escaped those regexes properly in Perl (the line number matches the regex with the backticks in). Backticks found where operator expected at /tmp/mycommand line 404, at end of line At the same time I started to doubt this approach and looked for a better one. (2) I then saw some Stackoverflow questions (here and here) that suggested a better solution. Here's the code: print("Processing..."); # Pass the arguments to ldapsearch by invoking open() with an array. # This ensures the shell does NOT interpret shell metacharacters. my(@cmd_args) = ("-x", "-T", "-1", "-h", "$gLdapPool", "-b", "$ldn", <snip> ); $lcmd = "ldapsearch"; open my $lldap_output, "-|", $lcmd, @cmd_args; while (my $lline = <$lldap_output>) { # I can parse the contents of my file fine } $lldap_output->close; The two problems I am having with approach (2) are: a) Calling open or system with an array of arguments does not let me pass > $lworkfile 2>&1 to the command, so I can't stop the ldapsearch output being sent to screen, which makes my output look ugly: Processing...ldap_bind: Success (0) additional info: Success b) I can't figure out how to choose which location (i.e. path and file name) to the file handle passed to open, i.e. I don't know where $lldap_output is. Can I move/rename it, or inspect it to find out where it is (or is it not actually saved to disk)? Based on the problems with (2), this makes me think I should return back to approach (1), but I'm not quite sure how to

    Read the article

  • How to write php->mysql queries?

    - by Bluemagica
    Is there any good tutorial that has all the basic rules for writing queries to store $_Post vars from php to mysql? Like when to use backticks and singleqoutes, and how to safely write code with functions like get_magic_quotes_gpc()? Another thing is, assuming there is no javascript validation(since the user can easily turn it off), how should I handle empty form fields being sent as empty $_post variables and throwing errors? Do I have to use isset() call on all the post variables? What is the best way to handle users turning off javascript validation on a form?

    Read the article

  • How to parse AMF data in Ruby?

    - by Matchu
    So I see that there are a few Rails plugins for serving AMF. However, is there a library that I can use in a Ruby environment to act as an AMF client: to read AMF data, and deserialize it into a Ruby object? If not, how could I best go about using tools built in other languages? I suppose I could write something in Python or Java or whatever, and call it from Ruby directly via backticks... but I'd first like to ensure that there isn't really any better option. Thanks!

    Read the article

  • Writing an app with Perl and Ruby?

    - by Jeff Erickson
    I am working on a project that is mostly Ruby on Rails. However, I need to generate and parse Excel files in this project (I know, I know...), so I've been using Perl's Spreadsheet::WriteExcel and Spreadsheet::ParseExcel which work well. However, what is the best way to combine this use of Perl with the larger Ruby on Rails app? Is calling the Perl script with backticks the kosher way to go about this? It feels a little hacky to me, but if that is the only (or best) way, then that's what I'll do. I wanted to reach out and see if anyone else has some suggestions or advise. Thank you!

    Read the article

1 2  | Next Page >