Software :: Pass Arguments In Scripts?
Dec 13, 2010I 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 RepliesI 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 RepliesI'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.
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]....
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.
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 RelatedI 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.
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.)
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 Related1. 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?
How to I use su to run a command, and pass arguments to that command, and not su?
ex: Code: su vmuser VBoxManage -q list runningvms I want -q to be specified to the VBoxManage command, not su. If I try any type of quotes it does not work either. Is there a way to do this?
I am using an Acer Aspire Timeline 4810TZ with F12 installed. I have to enter the kernel argument intel_iommu=off each time I boot. This means pressing escape, going to the correct kernel, pressing A (to change kernel arguments), and then entering the command. I've seen some sources that suggest editing /boot/grub/grub.conf, but I've tried it and it doesn't seem to make a difference. I'm wondering if maybe there's another file that I have to edit, because I don't see the kernel arguments in grub.conf that I see when I press A in the grub menu.
View 4 Replies View RelatedI 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:
I would like to get a log of all processes that are launched with the time that they were launched and the arguments they were launched with. Is this possible in Linux?
View 3 Replies View RelatedI 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?
I wrote a C program using Pthreads to compute the product of 2 matrices. Each element in the product matrix is computed in a separate thread. Eg: Thread (i,j) computes the element C[i][j] of the matrix C, where C=A*B. A is m*n, B is n*p, C is m*p. m,n,p are given as command-line arguments. A and B are initialized to random values from 1 to 10, while all elements of C are initialized to -1.But some threads do not get their arguments (i,j) correctly. So some elements C[i][j] still remain as -1, even after the program is over. My OS is Ubuntu 10.10 (Maverick Meerkat) 32-bit.I ran the program on another computer and it worked correctly. Is it due to a problem in the Pthreads library in my OS? Please help me. I have attached the source code.
View 3 Replies View RelatedI 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?
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 RelatedSuddenly, i have problems when i call a script when i use some arguments/variables
Here is my code:
Code:
This is my output:
Code:
How can I get the total arguments in perl.To be more specific if I try to execute the command
Code:
perl -w myperl.pl ash ok kumar
I should be able to get all the command line arguments.
I know that @ARGV will store only the arguments passed but not the entire arguments.
I ran installpkg on seamonkey 2.0.4, on Slackware 13.0, and it appeared to install OK. I can run /usr/bin/seamonkey -version and I get the 2.0.4 version number. However, when I run it without arguments, no windows get opened, and there are no errors that I have located (eg messages, syslog). This is probably something real obvious, but I'm drawing a blank. BTW, firefox runs OK.
View 12 Replies View RelatedI'm not really new to debian. Just never encountered this before. I'm not even sure how to describe that. The first time I realized something was wrong when I tried to create a file with dd:
root@strych ~# dd if=/dev/zero of=1GFile -bs=10M count=100
dd: bad operand `-bs=10M'
I mean what, I've done that many times before! Then I noticed that some commands started to behave this way:
root@strych ~# ls --help
--help: No such file or directory
On the other hand...
root@strych ~# fish --help
fish - the friendly interactive shell
or
root@strych ~# apt-get --help
apt 0.8.6 dla i386 skompilowany Oct 4 2010 11:55:22
Usage: apt-get [options] command
apt-get [options] install
So what the hell is wrong with my shell? This is persistent with any type of access: both ssh and local (physical), it's the same when I use sh, fish, bash or whatever. It also doesn't matter which user I'm logged in with. I haven't changed .profiles or anything concerning terminal really, besides installing fish but even that was long before I realised this problem. Actually, I can't think of anything that I've done that could do this. What am I missing? The system is debian testing with kernel 2.6.32-5-686.
How do I set ls so that when I type ls it actually runs ls -l. This Sounds minor but I'm trying to save keystrokes wherever I can. This is on Ubuntu 10.10.
View 4 Replies View RelatedI have a script gdrGltoDataRefresh.sh .while try to run the script it's giving:
And in log file it's giving:
i was wondering if someone could help me figure out a script for global variables i'm trying to set for a group of command line arguments:
basically i'm trying to set: if $# = 3 then i want to search for each all string $1 $2 $3
if $# = 4
then i want to search for each all string $1 $2 $3 $4
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
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]...
Whats wrong with this:
Code:
#include <stdio.h>
int main(int argc, char *argv[])
{
if(argv[4] == "-verbose")
{
printf("Verbose is on");
[Code]...
I'm trying to compile the hidtouch driver, but hit a snag. The error I get is
[code]....
Context: this is the driver for the touchscreen attached to an LTSP client. The server uses the AMD64 arch, the client uses the 1386 arch, both Debian. The client does start, but lacking a pointer device the pointer is useless. The build takes place on the server, in the i386 chroot of the LTSP setup. Basically, I'm stuck now...
I need to call functions that match an input string (if input str = "func1", call func1), so I have this:
Code:
#include <stdio.h>
#include <string.h>
void function_a(void) { printf("Function A
"); }
[Code].....
In the above example, the functions take no input arguments. Can they take a different number of arguments, for example, function_a(int), function_c(int, int), function_e(int, char, int)? How can I do that?
I want to know how to get eg. the contents of a form on a webpage which has been passed to a server side PHP script, inside for example an array which I can read. I've been reading a ebook on PHP which as far as I can see doesn't cover this inside it.
View 1 Replies View Related