Programming :: Bash Script : Pass Arguments To Second Level Parser?

Jan 14, 2011

I wrote a C++ program that uses two different parsers. The first parser is reading program arguments from command line:./mybin arg1 arg2 ...then during program execution there's an interactive prompt asking for more parameters:

...
>> (second bunch of arguments here)
...

I'd like to run my program inside a bash script, but I don't know how to give the second level arguments.

View 2 Replies


ADVERTISEMENT

General :: Bash : Pass Command Line Arguments Containing Special Characters?

Jul 14, 2010

I've written myself a linux program "program" that does something with a regular expression. I want to call the program in the bash shell and pass that regular expression as a command line argument to the program(there are also other command line arguments). A typical regular expression looks like "[abc]_[x|y]".Unfortunately the characters [, ], and | are special characters in bash. Thus, calling "program [abc]_[x|y] anotheragument" doesn't work. Is there a way to pass the expression by using some sort of escape characters or quotation marks etc.?

(Calling program "[abc]_[x|y] anotheragument" isn't working either, because it interprets the two arguments as one.)

View 7 Replies View Related

General :: Bash: How To Pass Command Line Arguments Containing Special Characters

Jun 24, 2011

I've written myself a linux program "program" that does something with a regular expression. I want to call the program in the bash shell and pass that regular expression as a command line argument to the program (there are also other command line arguments). A typical regular expression looks like "[abc]_[x|y]". Unfortunately the characters [, ], and | are special characters in bash. Thus, calling "program [abc]_[x|y] anotheragument" doesn't work. Is there a way to pass the expression by using some sort of escape characters or quotation marks etc.? (Calling program "[abc]_[x|y] anotheragument" isn't working either, because it interprets the two arguments as one.)

View 8 Replies View Related

Programming :: Pass In Mandatory Arguments First?

Jun 9, 2011

I am using getopts to take parse optional arguments but i also pass in mandatory arguments first

[code]
#!/bin/bash
print_usage()
{
perror "$@"
}
arg1="$1"
arg2="$2"
shift 2
[Code]....

View 8 Replies View Related

Programming :: Pass Arguments To A Function Using A Loop

Mar 1, 2010

I need to pass a large number of arguments to a function which takes variable number of arguments, such as gtk_list_store_new. But it doesn't look nice if i write something like gtk_list_store_new(NUM,TYPE_A,TYPE_B,TYPE_C,...,TYPE_OMEGA); because of large number of arguments. And, it will be a trouble to change number of columns because of need to manually change arguments to large number of such functions. So, how can i pass all the arguments to a function using a loop? Something like

Code:
for(i=0;i<NUM;i++)
{
push_arg(args[i]);
}
call_function(func);
?

Of course, i could just use asm code for this, but is there a portable way of doing so?

P.S. i mean C language.

View 2 Replies View Related

Programming :: Pass Arguments To Binary Cgi Program?

Mar 5, 2010

My hosting server does not allow exec() or system() calls, for security reasons. I can call a cgi process in two ways. From a .shtml page, i can issue a directive like code...

View 11 Replies View Related

Programming :: Bash Reading Arguments, Most Effective Way?

Aug 17, 2010

I've been reading about getopt and getopts but it doesn't seem like it's possible to parse arguments like --foo or even -foo. I've started my own script trying to achieve this, but I'm still wondering if I'm losing performance and if there is a better way to do this task.

Also I'm using the [[ =~ ]] regex syntax which seems to be available only in newer bash versions, should it be a big issue? My bash version: GNU bash, version 4.1.7(2)-release (x86_64-unknown-linux-gnu)

[Code]...

View 6 Replies View Related

Programming :: Passing Arguments To A Bash Source File?

Apr 24, 2010

Is it possible to pass arguments to a source file in a bash script? For example

#!/bin/sh
#
. /dir1/dir1/funclib -a -b

How would you check for the passed arguments in funclib without getting confused with any arguments passed to the main script?

View 5 Replies View Related

Programming :: Read Multiple Arguments In Bash Script?

Nov 24, 2010

First, I made a simply script which let me download a file from a filehosting site on my server, but I can only put one link there, so I need help how to put multiple links in.Here is my script:

Code:
#!/bin/bash
echo "Enter URL:"

[code]...

View 3 Replies View Related

Programming :: Make 2 Separate Arguments In 1 Bash Script?

Aug 31, 2010

This is what I have:

Code:
#!/bin/bash
#ascript.sh

[code]...

View 8 Replies View Related

Programming :: Can't Pass Variables To A Program In Bash Script / Fix It?

Dec 30, 2010

Trying to do a simple bash script, and having some issues. I am relatively new to bash, and did my best to search, but idk what exactly to search for.

Doesn't work code...

View 6 Replies View Related

General :: Pass All Arguments To A Function?

Jul 6, 2010

I've got a sticky little problem with a bash script. Please consider the following code:

Code:
#! /bin/bash
processArgs() {
echo "Count = $#"
while [[ $# -ne 0 ]]; do
echo $1
shift
done
}

processArgs $* If I call this script with Code: ./script first second third it'll print each of the argument on a new line - exactly what I would expect. However if I call it with

Code: ./script "Single Argument" "Second-Argument" it splits the first argument in two using the space as a delimitor. The problem appears to be the call to processArgs, where $* doesn't honour the quotes around the variables sent to the script.

View 4 Replies View Related

Software :: Pass Arguments In Scripts?

Dec 13, 2010

I am calling script 2 from script 1. Is it possible for me to pass the output from script 2 to script 1 as the value of a variable. for eg.. path=`/XXX/XXX/script2.sh`

View 3 Replies View Related

General :: Arch Usability - Pass Arguments From A Shell Script To A Program?

May 7, 2010

1. What file do i have to edit in order to include /usr/local/bin in the class path (ie. I put an executable in /usr/local/bin and when I try to execute it, it says the command cannot be found, etc.) EDIT: Solved, just didn't set PATH correctly. EDIT: New problem. When I try to execute a program in /usr/local/bin, it says "fopen: john.ini: File not found" Yet when i cd to /usr/local/bin, it doesn't say that. What would cause this?

2. Once I get my system setup the way i like it, how would i go about making it into a bootable CD/DVD?

3. How would I pass arguments from a shell script to a program?

View 4 Replies View Related

Programming :: Accessing SPI From Kernel Level And User Level

Jan 6, 2009

I want to know what are the advantages and disadvantages for accessing spi(serial peripheral inerface )from kernel level and user level. like methods of doing it, speed ,memeory utilization etc

View 1 Replies View Related

Programming :: Parser Symbols With Different Types

Nov 27, 2010

I decided to try making a programming language again after my last unsuccessful attempt, so now I figured how to write a good AST and it works great when the nodes are hard-coded into a test program. But to make a language out of it, I need a parser to build the tree according to an input file. I ran into a problem here:

YACC input file:
Code:
%{
#include "nodes/allnodes.h"
#include "Node.h"
int vars[26];
%}

%token SEMICOLON INTEGER VARIABLE IF WHILE DO OPAREN CPAREN OBRACE CBRACE
%right ASSIGN
%left NE
%left PLUS MINUS
%left TIMES DIVIDE
%% .....

As you might see, each nonterminal creates a Node* object and uses it as its value. The problem is that the literal tokens, however, don't return Node*'s and I don't know what to do. I would like to be able to convert literal tokens to nodes in the Lex file (which would avoid the problem), but the problem is with the assignment operator, which takes a Node* for the right-hand side and a variable name (not a Variable Node, because they just evaluate the the variable's value and you can't change the variable with them) for the left hand side.

View 14 Replies View Related

Programming :: Parsing XML Using Sax Parser In Java

Jul 7, 2011

I'll show the code first:

Code:

What I am after is to get the string text from the clip tags. But for now I just tested to see if it can finds the command tags and print something if it does. But it doesn't find it. Anyone knows why ?

Looks like the xml is not good, i test it with a xml validator:

Code:

View 1 Replies View Related

Fedora :: Bash Function With Arguments

Nov 16, 2010

I wanted to make an alias with arguments (like in cshell) which is in bash done by functions. The function must simply perform a command (nedit), append the arguments from the cli and make it run in the background (adding &).

So here is the function in a naive attempt:

Code:

when using the command

Code:

Code:

How can i use arguments and still start it in background? In cshell it was like:

View 8 Replies View Related

General :: Generating Two Bash Arguments From 'ls'?

Jul 3, 2011

I have a directory containing the following files.

Code:

1-res-opt-I189N-0001.pdb
1-res-opt-I189N-0002.pdb
1-res-opt-I189N-0003.pdb
1-res-opt-I189N-0004.pdb

[code].....

What I want is something like:

Code:

for i in *.pdb
do
python my_script.py 1-res-opt-I189N-00{1..10}.pdb 3-res-opt-I189N-00{1..10}.pdb
done

such that always the two files with corresponding index are submitted together to the Python script. How do I do that?

View 4 Replies View Related

General :: BASH Scripts Check For Arguments

Mar 5, 2010

I know that $1 ... $n will set the argument to the values but what happened if I have many options in one scripts lets suppose.

I can run:
myscript -1stargument -2ndargument -3rdargument
or myscript -1stargument
or myscript -1stargument -3rdargument

In my scripts I have
if [ $1 = "-1stargument" -o $2 = "-2ndargument"] #for every instruction I need
fi

but is there any way to do:
if [ (any arguments or commands) = "(mydesired option ] ; then
(do this...)
fi

View 6 Replies View Related

Programming :: Lilypond Parser For Python - Typeset The Content Of File

Nov 12, 2009

I'm woring on a personal research project and would like to know if there are lilypond parsers for python available or I'll have to create my own. Just in case you are wondering: I don't need to typeset the content of the lilypond file, just understand what's written in the file (what notes, what duration, when in time to play each one, etc). [url]

View 1 Replies View Related

Ubuntu :: Incrontab Not Passing Arguments To Bash Script

Feb 28, 2010

It seems incrontab wont see spaces properly at all. I setup a script to echo the arguments passed to it by incrontab to a file, and no matter what I put around the arguments on the incrontab file it will count a space as the next argument.

I have written a script to automatically retrieve imdb artwork for a given filename. Here is the script:

Code:

You can ignore all the commented "echo" commands that was just me testing. Anyway, the script work fine, however I am trying to use incrontab to monitor a folder, when a new (video) file is moved into the folder, it should execute the script and retrieve the artwork. My problem is, when incrontab passes the $# argument to my script, the script wont work because the spaces aren't escaped.

Here is some more detail:

Incrontab

Code:

Code:

The problem is, the script GetArtwork, doesn't see "Bangcock Dangerous" it just sees "Bangcock"

I have tried putting quotes around the $# in the incrontab - this just makes the script see "Bangcock (notice the single quote character)

View 2 Replies View Related

Programming :: Parse A File Using Html Parser By Libxml - Undefined Reference

Jan 13, 2011

iḿ trying to parse a file using html parser by libxml.

Code: #include <stdio.h>
#include <libxml/HTMLparser.h>
#include <string.h>
void main(){
printf("main
");
[Code]....

View 4 Replies View Related

Programming :: Use The Link Grammar Parser In Order To Do Some Part Of Speech Tagging?

May 12, 2011

Probably a stupid sounding question, but bear with me please. I need to use the link grammar parser in order to do some part of speech tagging. It's freely available and works once you run the makefile or 'make' it or however it's correctly said. Thing is, it has a C API which I intend to use. And once I ran a bit of the sample code given in the documentation it gave a whole host of errors. This is very confusing because I'm including the path for the folder that has all the header files.

gcc -I/path/include/ filename.c. But it still gives me errors about not being able to find things that are clearly defined there. An hour of trudging around the internet tells me I need to 'compile' the API first. I'm not exactly sure how or if I'm supposed to do that. If someone could just shed light on this it would be greatly appreciated. I grow increasingly cynical to the musical swell of my tiny brain rattling in my skull.

View 5 Replies View Related

Programming :: Develop An Html Template Parser Employing Flex & Bison?

Mar 23, 2011

I'm trying to develop an html template parser employing Flex & Bison, but now I found a problem and I don't know if surrender, so let's see if you can guide me to the solution (if any).

[Code]...

(Here I simplified the code to make only print what it gets, but it returns a token and the text to the bison program). Now my problem is that I would like to get the unknown characters as an unique string. [using the flex file above, returns char by char all HTML code that is not a comment!].

So, Could it be possible to make a flex rule that gets the HTML code?. It is not necessary to check if HTML code is correct I do it (before parse) using expat. Also there is no need to check the resulted code it will be done by the parser or compiler of the used language.

I know that are a lot of tools that uses this kind of templates in all languages and systems... but I'm just exercising my pour flex&bison skills. Also, using my current flex file, I have to remove the string "<!--MARKUP" from the beginning and "-->" from the end of returned string to bison... But in reality, if I could manage the HTML code as a flex rule, I could solve that sednding to bison an start Token, the code and and end token.

View 1 Replies View Related

General :: Passing Commands As Arguments To Functions In Bash Script?

May 31, 2010

I wrote a simple bash script to let me treat any set of programs like a deamon. For example if I configure the script a certain way I can start/stop/get the status of apache, mysql and php all from one command. I am having a bit of a problem though. I am passing commands as strings to a function and then depending on the arguments to the script it might run one of these commands or another. Some of these commands need to beun in the background though, such as deluge-web. When I send "deluge-web &" to the function and it execute it deluge-web does not start in the background. I can't figure out why this is. I have tried escaping the & with ''s and with a , but nothing seems to work. I know that this is some idiotic thing that I am overlooking, but I am a bit stumped. Here is the script configured to start/stop/get status of deluged and deluge-web.

Code:
#!/bin/bash
function checkanddosomething {

[code]...

View 3 Replies View Related

Ubuntu :: Bashrc Script Occasionally Cases -bash - Too Many Arguments Error

Mar 24, 2011

I have a .bashrc script to shorten the length of my shell path and occasionally I get the error:

Code:

I've tracked it down to this line

Code:

But can't seem to find anything wrong with it.

View 2 Replies View Related

Software :: Create A Command Line Inside A Bash Script That Contains Arguments?

Dec 9, 2010

I'm having problems with bash quoting. Maybe someone can tell me what's going on.. Basically, I need to create a command line inside a bash script that contains arguments that contain spaces and bash variables that need to be expanded.

[Code]...

View 5 Replies View Related

Ubuntu :: Parsing Textfiles And Passing Arguments In Bash To Preserve Tracker-tag Metadata

Sep 3, 2010

I'm at the bottom of the bash learning curve, looking up, hoping someone can toss me a line. I need to update tracker on my system but this will erase the metatag database I've been building up over the course of months for the purpose of indexing a news archive. So the solution seems to be, 1) save the output of tracker-tag to a text file for all relevant files within a directory, 2) upgrade tracker (since the version in the Ubuntu repositories is very much out of date) and then 3) use a script to parse the text file and pass appropriate arguments back to tracker-tag to rebuild the database. It sounds as though it ought to be simple enough, but I need a push in the right direction, which hopefully will not be off the cliff. Before I confuse my metaphors any further, here's what the text file looks like.

[Code]....

View 3 Replies View Related

General :: Pass A File That Changes Name To Another Command In Bash?

Jun 9, 2011

I frequently use wget to download tarballs and zip files from the web, then either untar then or gunzip them. I do:

Is there a way for me to automatically pass the zip file to tar or unzip WHILE wget-ting?

In pseudocode: wget google.com/somfile.zip && unzip

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved