General :: Arguments When Calling A Script ?
May 13, 2011Suddenly, i have problems when i call a script when i use some arguments/variables
Here is my code:
Code:
This is my output:
Code:
Suddenly, i have problems when i call a script when i use some arguments/variables
Here is my code:
Code:
This is my output:
Code:
(For function arguments): Scalar arguments are passed by value, which means that a copy of the argument is made for processing in the function, and changes to the argument in the function won't be reflected back to the calling program. Objects though, are passed by reference: any changes to them in the function are reflected in the calling program. What sense does this make? Why have they done this?
View 3 Replies View RelatedI 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 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'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'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 RelatedI have to call URL from shell script. E.g.: www.google.com. How can I call URL from the shell script.
View 6 Replies View RelatedHow 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 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 want to call a application file in user space through a character driver running in kernel space.
View 1 Replies View Relatedhow can you remove all the makefiles and whatnot and basically restore the source package to its original form after you've called "./configure" or even "make" ?
for instance you changed the source code then you ran ./configure then make then make install ....etc you checked the software and it functioned as you expected it does , now you want to remove all the makefiles and all that other jizz that you don't need or want anymore in the source (obviously in order to package it for distribution)
what is the "standard" method for doing so?
I have a script1.sh (see code below) which calls another script (which is a sort of template -> template.sh). But when i call template.sh i need to send an argument with it.
Code:
#!/bin/sh
VAR=`./template.sh -d $dirpath`
exitstatus=`echo $VAR`
[code]....
echo "$VAR files which are older than 1 hour in folder $dirpath" exit $exitstatus I geuss the command should look like something like this command
Code:
./script1.sh -d /
You don't have to look at the code of template.sh, thats not important. I just need to know how i get this to work I don't think it's that hard, but i just can't see it ...
I have 2 shell scripts, script1.sh and script2.sh. I call script2.sh from within script1.sh ( by simple ./script2.sh command). Based on some condition, i use exit 0 to exit out of script2.sh. I was trying to find if i can exit out of script1.sh as well at once. below is the example
script1.sh
#!/bin/bash
echo "Before ..."
[code]....
When i execute below is the output
Before ...
There was problem file is empty
The Script will Exit. Please fix the issue and run again...
After ...
I am trying to exit out of script1.sh as well so that i dont print "After ..."
I read somewhere that you should not be reading config space to determine the irq value to pass as the first argument to request_irq(). What is the proper way to determine the value of the 'irq' argument before calling this function? Hope this is the correct forum. I don't see one for drivers.
View 1 Replies View RelatedI'm pretty sure this is super simple, but I've searched and searched and for the life of me I can't find any info on how to limit the columns that display in the interactive top program with arguments passed from the command line. I recall seeing something formatted like this ...
~/top -f (kdx)
Which would only show the %CPU, UID, program name fields/columns. I'd like to display the results in a really narrow terminal window on the right side of my desktop.
how to pass an array as a command line argument in a shell script?
View 5 Replies View RelatedThe 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?
I am setting up a cron job, where i am calling a shell script to make few builds. I got struck at a point, need some expert inputs to proceed further. The script is categorized in 5 parts and in the last part while building software it asks for few questions like:-
1. Build mode choice
2. normal build
3. Copy Images
4. Arch
User manually has to input ans for these questions:-
1
yes
n
64
The ans's are fixed and this won't change. How shall i hard-code them or do something in the script so as when script flow reaches to this point it automatically take's these value. So far the cron job is not getting completed as it's waiting for user to key in these values manually. I had faced similar issue while building kernel modules but there it was easier as i had to take default values always:-
Error while calling capget function (EINVAL)
View 1 Replies View RelatedThe 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.
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]...
I am writing a scripts which involves for loop. I want to make use of arguments passed to scripts ranging from 2nd to last. I tried to use below
Quote:
kint `whoami`/root
for i in $2..$*
do
ssh root@$i "cd /local/0/home;mkdir -p $1/test"
done
I am trying to run it as below
Quote:
./scriptname webtech myserver1 myserver2 myserver3
and it gives following error Quote: ssh: myserver1..myserver2: name or service not known I basically want to pass arguments from myserver1 to myserver3 to the script.
I wanted to supply mplayer with the output of find command as arguments. The error returned showed spliced names of files whenever spaces occurred. I have subdirectories in my /home/my_user_name/Music/ directory, and in them multiple *.oga music files. The actual command that I issued was
Code:
mplayer $(find /home/my_user_name/Music/ -name "*.oga")
mplayer started but then was looking for broken file names. I am thinking quoting has to do with it to preserve the filename as one string but different attempts were met with inroads:
Code:
mplayer `find /home/my_user_name/Music/ -name "*.oga"`
gave me the same result and
Code:
mplayer `"find /home/my_user_name/Music/ -name *.oga"`
complained about wrong mplayer syntax.
I am trying (desperately) to setup freeNX so that I can access my Mandriva box from my Macbook over my network. I have great need to be able to do this. Here's the necessary info for you: Mandriva PC: running Mandriva 2010.0 with freeNX installed from the Mandriva repos Macbook: running OS 10.4 with the Nomachine NX Client installed Now, I have followed the setup from the Mandriva wiki as well as the freenx wiki to no avail. I simply cannot connect the Macbook's NX client to the server. I get an authentication failed message. However, I can ssh from the Macbook to the server just fine (that's how I'm getting most of this work done).
[Code]...
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?
Back when I was first learning Linux, one of the questions that I kept wondering about was "what are all these files and directories for?" I couldn't find a resource that would explain them in a digestible manner. Specifically, I was looking for one that would allow me to look at a Linux filesystem interactively, collapsing and expanding folders to look at just the ones I was interested in at the moment. So later, when I got the opportunity, I wrote it.
But despite a ton of research, I'm still not totally knowledgeable on the subject. The most important thing I'm looking for right now is for experienced Linux/Unix people to tell me where I got stuff wrong, and for newbies to tell me how useful it is to them and which things need clarification. I'm also interested in technical and graphical ways to improve usability, like better icons, layout, etc. I know I need to be able to collapse long descriptions, but what would you like to see? The Works Cited list and a full introduction are still on the way as of this writing.
Without further ado: Linux Filesystem Hierarchy Explanation. You'll need a fairly recent browser that can handle XSLT; the actual info is stored as XML, and transformed into HTML with an XSLT stylesheet. This is still a work in progress, and I'll be updating it as the thread progresses.
Finally, would people be interested in collaborating with me on this, as an open-source project? I've never done anything like that, and I'm not sure how much time I'll be able to give it in the future, but I really think this should be continued and expanded.
Edit: Works Cited and decent intro are now in place.
how to run a shell script taking command line arguments in a jsp page.
View 1 Replies View RelatedHow can i write a shell script that takes a file path as command-line arguments.and it should report whether the path denotes a file or a directory.
View 2 Replies View Related