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


ADVERTISEMENT

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

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 :: 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 :: How To Set Incrontab In Bash Scripting

Mar 7, 2011

I have a question;

Is it possible to set incrontab in bash script? I tried to set normal crontab and it works like a charm but unfortunately not "incrontab"

I have two bash files; test-incrontab.sh and addlinetocrontab.sh and here are the contents of these files respectively;

Code:

Code:

As you can see there are two enteries in each file. One for normal crontab and other one for incrontab. When i run "test-incrontab.sh" like following;

Code:

crontab works perfectly and i can see cron job set but for incrontab it just does not work. No error either!

I am only getting this back "table unchanged"

View 2 Replies View Related

Ubuntu :: Passing Arguments In Commandline

Mar 13, 2011

I have some source code of an application called gmapping.

I am pasting the source code documentation below:

SCANMATCHER:

How do I run this file. When I enter the filename parameter, and press enter, I get

COMMAND LINE: parameter aces not recognized no filename specified

GridFastSlam: Initialization Error!

(Did you specified an input file for reading?)

What is the right line to type in the terminal to sun this code?

View 1 Replies View Related

General :: Passing Program Arguments To Gdb?

Nov 18, 2009

I'm using gdb to debug my program. My program requires arguments (e.g., ./prog -dfile).But if I use gdb as in gdb ./prog -dfile, gdb wants to interpret the -d argument. How do I pass an argument to my program via gdb?

View 2 Replies View Related

Programming :: Passing Arguments To A Child Process In C++?

Feb 7, 2010

what I am trying to do is to pass an argument to the standard input stream of a child process. I mean I create two programs .. first one invokes the other. second one contains something like

Code:

scanf("%d", &n);

now I want my first program to be able to pass a value to the second one so that it gets stored in n.

View 7 Replies View Related

Programming :: Passing Arguments To System Command?

Dec 17, 2009

I am calling another executable in my application (C programing) using "system" command
which is user interactive program. now i want to pass those args in system command only.

system(" executable ");

Executable will expect 1,2 or 3.

1 is to continue
2 for do changes in settings
3 exit from application

how to pass these in to system command

View 1 Replies View Related

Programming :: Syntax For Passing Arguments In Csh Aliases?

Mar 22, 2009

I want to write a little time-saving alias for my .cshrc file that will move files and then cd to the directory I've moved them to. What I can't quite figure out is the syntax to say 'move all the arguments except the last one.' Here is what I have:

alias follow 'mv !:1-$-1 !:$; cd !:$'

This actually seems to work, but it also gives me an irritating error:

mv: cannot stat `destinationdirectory/-1': No such file or directory

Similarly, I tried:

alias follow 'mv !:*$#argv-1 !:$; cd !:$'

Again the move and cd are successful, but again there is an error:

mv: cannot stat `destinationdirectory/0-1': No such file or directory

View 1 Replies View Related

General :: Passing An Array As Command Line Arguments?

Apr 2, 2011

how to pass an array as a command line argument in a shell script?

View 5 Replies View Related

General :: Passing Multiple Arguments In Shell Script?

Dec 11, 2010

The script receives multiple files as parameters and it is supposed to count the number of lines in each of them and write that number in another file.

This is my script:

Code:

while [ -n "$1" ]
do
lines=`cat $1 | wc -l`
echo "The number of lines in file $1 is $lines." >> lines.txt
shift
done

Is there any other way to do the same thing, without using shift?

View 7 Replies View Related

Programming :: C Syntax - Passing In Unknown Number Of Arguments?

May 18, 2009

I need to write a wrapper function around the mvprintw function, like so:

int smvprintw( ? )
{
// Do various checks/modifications on the first two arguments (int y,
int x) first,
// and then
return mvprintw ( ? );
}

How should I write the args for smvprintw so that I can pass all the data correctly to mvprintw, and also do my checks on the first two args (for example, to modify them)? I'm confused by the prototype of mvprintw: This is mvprintw as listed in the man pages:

int mvprintw(int y, int x, const char *fmt, ...);

And this is how I saw it in ncurses.h:

extern NCURSES_EXPORT(int) mvprintw (int,int, const char *,...)

I believe the "..." refers to the unknown number of items after const char * fmt. Will it suffice to do something like "int smvprintw(int y, int x, const char * fmt, void * etc)" and then "mvprintw(y, x, fmt, etc)" inside the function?

View 2 Replies View Related

Programming :: Case Statement Passing Multiple Arguments?

Aug 7, 2010

I've started dabbling with the case statement in order to pass some option's arguments into variables. I do not think I am doing this right.

Code:

usage() {
echo "Usage: $0 [-z|--snooze] [-c|--channel] [-p|--playlist]
[-m|--message] [-v|--mpcvolume]"

[code]....

As you can see, I want to pass arguments depending on the option(s) chosen by the user; ie. --snooze, or --channel. By default, if no options are chosen, I'll display a usage message; though in the future I'll provide some sane defaults. I'd like to create a case statement to handle passing arguments to any number of options; something like:

Code:

wakethehellup.sh --snooze 20 --message 'wake up!'

and for the other arguments, it would have a default set. The case statement I provided fails with a syntax error "syntax error near unexpected token `$2'" near the '--snooze' in the statement, so I take it you can't pass a parameter in this way; but I'm confused as to how I'm supposed to pass different parameters to different options without the options being confused as parameters.

View 2 Replies View Related

General :: Scripting - Try To Passing Arguments To For Cycle - Inside A Function

Apr 26, 2011

The code:

Quote:

Problem: I need a method to maintain the $i variable. In fact, actually, this variable get lost when executed. I think that an escape can preserve this variable and permit its execution inside the function, but I've no idea about.

View 3 Replies View Related

Programming :: Passing Command-line Arguments To Qglviewer Application?

Jul 13, 2009

how to use QGLviewer. I want to give my program a file name as a command line argument. All of the sample programs I find have a main.cpp file like this:

Quote:

#include <QApplication>
#include "window.h"
int main(int argc, char *argv[])

[code]....

Then the Window class, which is derived from QGLViewer, does all the program's actual work. If I want access to argc and argv, for example, to open and read a file that's passed as an argument, what would handle that? Is there a built-in way to get the arg variables to the window class, or do I need to just write a loadfile function and pass them?

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 :: 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 :: 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

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

Programming :: Bash - Passing Variable To Ssh?

May 8, 2010

I have a file with around 1000 IP addresses in it and I need to be able to ssh into each one of them, run a single command, and then exit. I already know the ssh command I want to run and it looks like this:

Code:

shpass -p [password] ssh -p 10022 -o StrictHostKeyChecking=no root@[ip variable] 'reboot'

(I know shpass is not good to use and keys are the correct way but I don't have any other options in this scenario.) if these ip addresses were in a .csv file, by themselves with no other information, how would I create a script to do the above command to each ip until the end of the file?

View 8 Replies View Related

Programming :: Passing A Variable To Bc In Bash ?

Jan 14, 2009

I cannot for the life of me get this little (simple) script I wrote to work. Here is the entire script:

Code:

#!/bin/bash
ASPECT=`mediainfo $1 |grep "Display aspect ratio" |cut -d : -f 2`
HEIGHT=`echo "320 / $ASPECT" |bc`
SIZE=`echo 320x$HEIGHT`

[code]......

An input filename ($1) is fed into mediainfo, which by the use of grep and cut spits out a single number which is the aspect ratio. This is then divided by bc into 320, which gives the desired height dimension for the file that I want ffmpeg to create for me. Finally, ffmpeg runs using the calculated dimensions... Basically, it's the passing of the $ASPECT variable to bc that seems to fail. It looks like bc won't read the output from the mediainfo line... It always crashes out with:

Code:

(standard_in) 1: illegal character: ^M I've tried doing something even simpler like this to debug by just trying it to display the calculation on the screen:

Code:

#!/bin/bash
ASPECT=`mediainfo $1 |grep "Display aspect ratio" |cut -d : -f 2`
HEIGHT=`echo "320 / $ASPECT" |bc`
echo $HEIGHT

and it does the same, so it's definitely bc that won't accept the output from mediainfo.

View 4 Replies View Related

Ubuntu :: Passing Commands To A Subshell In Bash Scripts?

Sep 24, 2010

I was reviewing some scripts written by a person that does not work with us anymore and I found a chunk of code I'd like to know more about.

Code:
mycli <<! >> /var/myprogram.log
command_1

[code]...

View 2 Replies View Related

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 View Related

General :: Bash - Passing Commands To CLI Using A Script

Jul 31, 2011

is there any way I can pass commands to the CLI of a tool directly?

I would like to script some actions, for example:

./OpenBTS < "tmsis"

I do not need to retrieve the results (I watch it in the log file). how I could realize that? There is now way to do this using command line parameters, at least not that I found out. So it looks like I have to figure out sth myself. Maybe I could automate screen in a way to detect the prompt and "paste" my command there. Are there tools for this on Linux?

View 3 Replies View Related

Programming :: Passing PHP To Bash Script And Then Back?

Jul 15, 2010

I have a bash script called bash I am trying to execute from PHP. I think I have that right (not sure yet). Ideally let me explain what I am doing. The front end will pass a variable from a text entry box, called New_Task, the New_Task needs to be executed in the bash script and the output needs to be displayed back on the front end. So let me give some code and let me know what you all think.bash code is quite long, but essentially it is made to take a entry and create a task out of it. eg. "svn branch <Task Name>". The code below is getting the New_Task variable passed from the text entry box ($NewTask) and I have an exec for the bash script, but I am not sure it is working, I need to add some code to see the input in the front end.PHP back end code:PHP Code:

function mTaskCreator()
{
$strAction = $this->_objUserContext->mGetPostVar( 'acti

[code]...

View 7 Replies View Related

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







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