Programming :: Can't Invoke A Command From Within Shell Script / Sort It?
May 17, 2010When I try to invoke 'source' command from within a shell script, namely, myscript.sh, I get the following error message code...
View 1 RepliesWhen I try to invoke 'source' command from within a shell script, namely, myscript.sh, I get the following error message code...
View 1 RepliesWhat options should I use when I'm using the sort command to sort the top 5 CPU processes (ps -eo user,pid,ppid,%cpu,%mem,fname | sort ??? | head -5) showing max to min usage?
View 2 Replies View RelatedI am trying to import variable values from a profile file to a perl program.
I am using the below command for doing it.
Quote:
system (". /opt/bbfb/bin/setbbfbenv $codeset");
the above command does make variable values available to the running perl program..
Can some one help me on this front..
I am running a Java application on the command line bash terminal under Mint Debian. I have JDK1.6.0_22 installed 64-bit, and the OS is 64-bit too. I have a few JAR files in the directory and a few native LWJGL libraries. When I run the application using the command line, all works fine.
Lets assume my directory where the files are is called /home/riz/MyGame. I change to that directory and this is the command I use code...
We switched from unix to linux and we have an old report that extracted data from a database, output to an ascii file and then sorted the results in the file based on different arguments. The report now blows up when it runs,and I can only guess it is because the options for sort on linux differ slightly from unix.For example, here is one of the commands issued from within the report app that ran on the old unix box:
if sort-sequence = "descending" then
'sort -t~" -f +3.0f -4.0 +5.0r -6.0 -f '
else
'sort -t~" +3.0f -4.0 +1.0f -2.0 -f'
I will eventually rewrite the report to store the data in a local table, but I can simply adjust the options to suit the requirments of linux. Basically, I need to know if this can be a quick fix for the short term.
I just wonder the distinction calling the function between $(one_function) and one_function in bash shell script.
When I set the variable PS1 in ~/.bashrc, I can't invoke the function by one_func
ex:
export PS1="
[e[31m] $(one_func) # it works
export PS1="
[e[31m] one_func # it doesn't work
I am using gtk to program GUI. How can I show the output of shell command into a textbox, ex ps -efc command ?
View 3 Replies View RelatedI have a problem, I need to launch another binary from my application, but I need to get the control back once the other binary is initialized. fork/exec doesn't seem to give anything on that side using pthreads I'm able to wait until the new thread exits, but that's not what I want at the moment I'm using popen, but it doesn't seem to do the job right...
View 14 Replies View RelatedHere is what I am doing I have a file, a.txt for example, with following contents:
Code:
coreutils install
cpio install
cpp install
cpp-4.3 install
dbus install
[Code]...
So it seems like the sorting algo. for dpkg --get-selections is different than sorting algo. of 'sort' command when it encounters "-" (hyphen). How can I sort the original file (a.txt) in such a way that it produces the output file ,b.txt, exactly the same.
I have to execute certain commands (like shutdown Tomcat) on several servers so I'm using a loop and ssh. I put the server's IP on a CSV file which I parse, execute the commands for each line and send the output to a file. The problem is that after processing one line the program stops execution. I wonder if someone could lend me a hand with this, I'm new in bash scripting and I ran out of ideas.
The CSV (servers.csv) file looks like this:
Code:
192.168.254.5:Server 1
192.168.254.6:Server 2
...
And the script looks like this:
Code:
#!/bin/bash
while IFS=: read ip name
do
sshpass -p "pass" ssh -o "StrictHostKeyChecking no" root@"$ip" 'sh <CATALINA_BASE>/bin/shutdown.sh' >> output.log
done < servers.csv
How to use shell command?
installs.sh:
Code: Select allapt-get install icedove-l10n-hu
apt-get install rar
apt-get install ...
...
y press key or other language is other key. hungarian key is: i
english after apt-get install in gnome-terminal: (y)es or (n)o
hungarian after apt-get install in gnome-terminal: (i)gen or (n)em
How to yes or no automatically in all languages? Not manual, not 'Y'/'I' or 'N'/'N' keydown.
I would like use this script my fresh installed Debian 7.1. I would like run this install.sh when Debian is installed for my all softwares when i would like use.
10 PC installing easy and faster my script.
If no script is slowly install for my 10 PC.
I would like to know if there is any way to detect a command if it going to be executed in the shell?
Eg:
Cmd: sudo apt-get clean I want a C program to be called before this cmd is executed.
what we are trying to do is, to let the customer click a button in the web browser, and then the web server to call a shell script to do the work. The output from the stdout && stderr of the script should be displayed in the web browser once finished or timeout, along with the exit code of the script.
The shell script is however not on the web server, but on another app server. So to call this script from the web server as the identity 'tomcat':
Code:
$ sh appuser@app-server:$appbin/app-script
The .ssh/id_rsa.pub thing is done, and we have no problem doing this in the command line so far.
Our loaded ex-colleage has left us the webpages (jsp) with code like these:
Code:
<%@ include file="jsp_functions.jsp" %>
<%
String cmd = "sh $appbin/app-script";
ExecResult r = new ExecResult();
[Code].....
My main problem right now is doing floating point arithmetic within a bash script, with variables.Right now I have a folder called "myExamples" with a script called "run_example" that runs with no issues.I plan to(1) create many folders inside [myExamples], that are named [example10] [example11]...each containing an identical copy of (run_example),(2) modify Line 172 of each copy of (run_example)...in one copy, it would be 3.00, the next copy would have 3.05, etc. (This part doesn't work!)How can I use the available calculator bc code to do floating point operationsMy code is below -
#!/bin/sh
# run from directory where this script is
cd `echo $0 | sed 's/(.*)/.*/1/'` # extract pathname
[code]....
I'm working on an application which generates random shapes when clicking on a window. I designed the window using Motif. I want to invoke the ButtonPress Event .
View 1 Replies View RelatedI have created a glade file which so far have two regions in it:
1) On the right division is a toggle button which calls a C script when enabled.
2) I have a drawing area, in which I would like to plot a point (X-Y scatter plot). The plot should be generated dynamically using a C script. I am not sure how the integration between the two is possible for a drawing area.
In glade what properties of drawing area should I set? eg.expose event, realize etc. I was thinking of using cairo for generating the plot.
I am able to invoke 'skype' using the following command in a Terminal window. < export XLIB_SKIP_ARGB_VISUALS=1 && LD_PRELOAD=/usr/lib/libv4l/v4l2convert.so && skype & >. I want to be able to enter it through the Gnome Application interface. I right click on the skype icon and went to properties and added the above code. When I click the icon I get the following error message set out on the attachment? properly enter the commands within the application Command: line?
View 2 Replies View RelatedMy computer is connected to the college lan where almost all machines are some variant of Windows OS. If i use Places > Network, while windows network is displayed, mostly it returns unable to mount shares, my workaround for this problem is I use some tool like nbtscan to see which hosts are up and then use network > Connect to Server > windows share and type in the ip address, this mounts the windows share even though Places> network doesn't display such hosts. My question is there some command line way where I can invoke nautilus to mount the windows share, ie the same job connect to server > windows share does? And is there some application like say lan surfer for windows which lists all the folders shared by a windows client.
View 3 Replies View RelatedMy server pretty often becomes full up php processes running which are not needed. Is there a way to search for and kill any php process that is more than 3 hours old?
View 7 Replies View RelatedI have the following code :
Code:
E_BADARGS=65
if [ $# -ne 2 ] ; then
[code]...
My server pretty often becomes full up php processes running which are not needed.Is there a way to search for and kill any php process that is more than 3 hours old? as I understand it, i need to use ps piped with awk. awk at the moment seems very complicated to me, do not how to start tackling it.
View 5 Replies View RelatedThis is weird. I have a shell script with no execute rights.$ chmod -x test.shThen I try$ test.shwhich does not work. (I have "." in PATH)When I do$ . test.shit works! I can run the script even though I have no execute rights. Why is that?Another question: If I have a shell script without a hash bang, I still can execute the shell script. Why? What does hash bang do? If there is no hash bang, why is the shell script run? What does the hash bang do
View 9 Replies View Relatedwhen I execute the command from the shell command line - it works and no error code.if I do the exact same command from a perl file - it fails with code 32512.the file is created from the same perl script that runs the command that fails. file permission is 0664.
Code:
#! /usr/local/pkg/perl-5.8.8/bin/perl
print "Content-type: text/html
[code]...
How can we fire a shell command like ls,./a.out automatically in kernel space via a kernel module ? i.e. replacement of system() function of user space into kernel space.We need to develop a kernel module which can fire some shell command let say "firefox [url]" automatically to open google automatically from module.
View 2 Replies View RelatedIf say, I want to read the input given by user at the command prompt and write a code to execute the cmd given then which commands do i use to implement this ( Im writing the code in C )?
View 8 Replies View RelatedDoes anyone know a method of being able to process the complete and literal command line passed to a shell script ? I want to have the command line parameters with ALL characters (including meta characters e.g. $ literally).
So as if there was no shell to substitute or expand parameters nor applying it quoting rules.
I have a command that outputs n lines of text, and I want to place each line into an array element, but I can't seem to get the syntax correct
So my command is this:
cat $configfile | sed -n '/cluster:'$clustername'/,/cluster/ p' | awk /host/
Which produces many lines depending on the value of $clustername. I'd like to get each line as elements of an array.
I have written the following script in my linux server to add users for LDAP database.But i can't able to run this.
The script is as following
#!/bin/bash
echo "Mention the username which you want to convert LDIF format"
read username
if ["$username" -e "/ldiffile/passwd"]; then
echo "Username already exists"
else
cat /etc/passwd | grep -i "$username" >> /ldiffile/passwd
fi
The output which i got :
. ldapadd.sh
Mention the username which you want to convert LDIF format
yal2361
-bash: [yal2361: command not found
please let me know where need to change and what
I wonder if there is anyway to make a user-defined bash shell function global, meaning the function can be use in any bash shell scripts, interactively or not. This is what I attempted:
Code:
$ tail -n 3 /etc/bashrc
echotm () {
echo "[`date`] $@"
}
[code]....
I am trying to fix a perl script, and I really suck at perl. But I think this problem will be easy for people who know it.
The problem is, I have an old setup script someone wrote many years ago. It fails if the standard shell is dash and not bash. The only way I've gotten it to work is to point /bin/sh to bash. I looked thru the script and it uses "system" many places, and I think that's the problem.
I searched for it and found this link:url
My plan is to include this function:
Code:
sub system_bash {
my @args = ( "bash", "-c", shift );
system(@args);
}
Then I could simply change all calls to system into system_bash and it should work?
The parameter to the system calls is usually some variable. What if the parameter is a list already? Do I need to test for it somehow, and if it's a list, prepend "bash" and "-c" to the list? How do I do that?
In the script there are lots of places like this:
my $error = system($cmd);
if ($error) {
die/warn "some error message";
}
Shouldn't there be a return in the system_bash function?