Search Results

Search found 4958 results on 199 pages for 'shell'.

Page 17/199 | < Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >

  • Executing shell commands from Java

    - by Lauren?iu Dascalu
    Hello, I'm trying to execute a shell command from a java application, on the GNU/Linux platform. The problem is that the script, that calls another java application, never ends, although it runs successfully from bash. I tried to debug it: (gdb) bt #0 0xb773d422 in __kernel_vsyscall () #1 0xb7709b5d in pthread_join (threadid=3063909232, thread_return=0xbf9cb678) at pthread_join.c:89 #2 0x0804dd78 in ContinueInNewThread () #3 0x080497f6 in main () I tried with: ProcessBuilder(); and Runtime.getRuntime().exec(cmd); Looks like it waits for something to finish. Any ideas? Thanks, Lauren?iu

    Read the article

  • Show last command with up arrow on a linux c shell

    - by nunos
    I have implemented a simple linux shell in c. Now, I am adding some features and one I immediately thought about was to be able to show the last commands with the up arrow. Question 1: However, I have no idea how to accomplish this. Do you? Question 2: Any comment on how to store the "history" commands are also appreciated. I suppose something like a queue which allows access to all elements would be a good idea. Am I wrong? Do I have to implement it or is there already some good implementation out there I should know about? Thanks.

    Read the article

  • Setting variables in shell script by running commands

    - by rajya vardhan
    >cat /tmp/list1 john jack >cat /tmp/list2 smith taylor It is guaranteed that list1 and list2 will have equal number of lines. f(){ i=1 while read line do var1 = `sed -n '$ip' /tmp/list1` var2 = `sed -n '$ip' /tmp/list2` echo $i,$var1,$var2 i=`expr $i+1` echo $i,$var1,$var2 done < $INFILE } So output of f() should be: 1,john,smith 2,jack,taylor But getting 1,p,p 1+1,p,p If i replace following: var1 = `sed -n '$ip' /tmp/list1` var2 = `sed -n '$ip' /tmp/list2` with this: var1=`head -$i /tmp/vip_list|tail -1` var2=`head -$i /tmp/lb_list|tail -1` Then output: 1,john,smith 1,john,smith Not an expert of shell, so please excuse if sounds childish :)

    Read the article

  • Shell script not picking up password file...

    - by BigDogsBarking
    Running the below shell script seems to ignore the password file I'm feeding it. I'm continually prompted for it. If I enter it, the rest of the script goes without a hitch, but as I'm running it via cron, I really need to get it to read from the file... Any suggestions? #!/bin/sh p=$(<password.txt) set -- $p pass_phrase=$1 destination="/var/www/d" cd /var/sl/ for FILE in *.pgp; do FILENAME=${FILE%.pgp} gpg --passphrase "$pass_phrase" --output "$destination/$FILENAME" --decrypt "$FILE" rm -f $FILE done

    Read the article

  • shell script problem: does not work on the terminal, but works in a script

    - by jrharshath
    Hi, I was playing with shell scripting, when a strange thing happened. I need someone to explain it. I have a file 'infile', contents: line one line2 third line last a test script test.sh, contents: read var1 echo $var1 i executed: cat infile | ./test.sh output was line one Then I did: cat infile | read var1 echo $var1 Result: a blank line. I even tried cat infile | read var1; echo $var1; same result. why does this happen?

    Read the article

  • Best way to choose a random file from a directory in a shell script

    - by jhs
    What is the best way to choose a random file from a directory in a shell script? Here is my solution in Bash but I would be very interested for a more portable (non-GNU) version for use on Unix proper. dir='some/directory' file=`/bin/ls -1 "$dir" | sort --random-sort | head -1` path=`readlink --canonicalize "$dir/$file"` # Converts to full path echo "The randomly-selected file is: $path" Anybody have any other ideas? Edit: lhunath makes a good point about parsing ls. I guess it comes down to whether you want to be portable or not. If you have the GNU findutils and coreutils then you can do: find "$dir" -maxdepth 1 -mindepth 1 -type f -print0 \ | sort --zero-terminated --random-sort \ | sed 's/\d000.*//g/' Whew, that was fun! Also it matches my question better since I said "random file". Honsetly though, these days it's hard to imagine a Unix system deployed out there having GNU installed but not Perl 5.

    Read the article

  • Shell Script - comparing lines of text, deleting matches

    - by SirRatty
    Hi all, I've done some searching for this but cannot find what I'm after, specifically. I have two files: "a.txt", "b.txt". Each contains a list of email addresses, separated by newlines. For all lines in "a.txt", I need to check for a match anywhere in "b.txt". If so, the email address in "a.txt" needs to be removed. (Alternatively, a new file "c.txt" could be created with the output if that is easier.) I'm using Mac OS X, so am looking for a shell script that could help, or pointers to how I'd go about constructing the script. Thanks for any help.

    Read the article

  • run program multiple times using one line shell command

    - by teehoo
    I have the following gifs on my linux system: $ find . -name *.gif ./gifs/02.gif17.gif ./gifs/fit_logo_en.gif ./gifs/halloween_eyes_63.gif ./gifs/importing-pcs.gif ./gifs/portal.gif ./gifs/Sunflower_as_gif_small.gif ./gifs/weird.gif ./gifs2/00p5dr69.gif ./gifs2/iss013e48788.gif ...and so on What I have written is a program that converts GIF files to BMP with the following interface: ./gif2bmp -i inputfile -o outputfile My question is, is it possible to write a one line command using xargs, awk, find etc. to run my program once for each one of these files? Or do I have to write a shell script with a loop?

    Read the article

  • How to kill all subprocesses of shell?

    - by depesz
    I'm writing bash script, which does several thing. In the beginning it starts several monitor scripts, each of them runs some other tools. At the end of my main script, I would like to kill all things that spawned from my shell. So, it might looks like this: #!/bin/bash some_monitor1.sh & some_monitor2.sh & some_monitor3.sh & do_some_work ... kill_subprocesses The thing is that most of these monitors spawn their own subprocesses, so doing (for example): killall some_monitor1.sh will not always help. Any other way to handle this situation?

    Read the article

  • Shell script for testing

    - by Helltone
    I want a simple testing shell script that launches a program N times in parallel, and saves each different output to a different file. I have made a start that launches the program in parallel and saves the output, but how can I keep only the outputs that are different? Also how can I actually make the echo DONE! indicate the end? #!/bin/bash N=10 for((i=1; j<=$N; ++i)); do ./test > output-$N & done echo DONE!

    Read the article

  • Regarding Shell variable

    - by arav
    I need to call another shell script testarg.sh within my main script. This script testarg.sh has arguments ARG1 ,ARG2, ARG3. I need to call up the below way ./testarg.sh -ARG1 -ARG2 -ARG3 ARG1 and ARG3 argument Variables are mandatory ones. If its not passed to the main script then i quit. ARG2 is an optional one. If the ARG2 variable is not set with value or it's not defined then i need not pass it from main script.So i need to call up the below way ./testarg.sh -ARG1 -ARG3 If the value exist for the ARG2 Varibale then i need to call the below way ./testarg.sh -ARG1 -ARG2 -ARG3 Do i need to have a if else statement for checking the ARG2 variable is empty or null. Is there any other way to do it.

    Read the article

  • "set -e" in shell and command substitution

    - by ivant
    In shell scripts set -e is often used to make them more robust by stopping the script when some of the commands executed from the script exits with non-zero exit code. It's usually easy to specify that you don't care about some of the commands succeeding by adding || true at the end. The problem appears when you actually care about the return value, but don't want the script to stop on non-zero return code, for example: output=$(possibly-failing-command) if [ 0 == $? -a -n "$output" ]; then ... else ... fi Here we want to both check the exit code (thus we can't use || true inside of command substitution expression) and get the output. However, if the command in command substitution fails, the whole script stops due to set -e. Is there a clean way to prevent the script from stopping here without unsetting -e and setting it back afterwards?

    Read the article

  • what does < < mean in the shell

    - by stib
    when looping recursively through folders with files containing spaces the shell script I use is of this form, copied from the internet: while IFS= read -r -d $'\0' file; do dosomethingwith "$file" # do something with each file done < <(find /bar -name *foo* -print0) I think I understand he IFS bit, but I don't understand what the < < characters mean. Obviously there's some sort of piping going on here.. It's very hard to google "< <", you see. TIA -stib

    Read the article

  • Shell script variable problem

    - by user280288
    Hi all, I'm trying to write a shell script to automate a job for me. But i'm currently stuck. Here's the problem : I have a variable named var1 (a decreasing number from 25 to 0 and another variable named var${var1} and this equals to some string. then when i try to call var${var1} in anywhere in script via echo it fails. I have tried $[var$var1], ${var$var} and many others but everytime it fails and gives the value of var1 or says operand expected error. Thanks for your help

    Read the article

  • Shell Scripting For loop Syntax Error

    - by NewShellScripter
    Hello, I am trying to make a simple shell script to ping a source but I am getting bash-2.03$ ./test.sh google.com 10 .5 /home/users/me 16 256 ./test.sh: line 35: syntax error near unexpected token `((' ./test.sh: line 35: `for (( i = 1 ; i <= $totalArguments ; i++ ))' This is the code: #!/bin/bash ip=$1 count=$2 interval=$3 outputDirectory=$4 shift; shift; shift; shift; totalArguments=$# for (( i = 1 ; i <= $totalArguments ; i++ )) do ping -c $count -i $interval -s ${!i} $ip >> $outputDirectory/${!i}results.txt done Can someone tell me what I am doing wrong with the for loop syntax? Thanks!

    Read the article

  • How to warn for the use of unset variables in a korn shell script

    - by Lepu
    Is there any way to throw errors or warnings in a korn shell script to prevent the use of unset variables ? Let's assume I have a temporary folder that I want to remove. TEMP_FILES_DIR='/app/myapp/tmp' rm -Rf $TEMP_FILE_DIR #notice the misspelling How to prevent this kind of mistakes before they actually happen? I know the script should check for file existence and empty string before attempting to remove, this is just a silly example to illustrate a mistake that could have been avoided with some warnings. I don't know if this feature exists in ksh. If it does exist, how do you turn it on?

    Read the article

  • Wrong command in shell

    - by jask
    I have this command in a shell archive: sh -c $POSTGRESbin'psql -U '$POSTGRESuser' -h localhost -d '$POSTGRESdb' -c "select preview from '$fildCatalog' where preview <>'nodata' and id_registro in (select distinct(id_record) from e3_article_items where id_catalog=2101 and id_article in (select id_article from document_articles where id_document in(select distinct(id_document) from p3_logical_pages where id_logical_page in (select id_logical_page from p3_flatplan_pages where id_edition=1536 and id_logical_page is not null order by cast(pagenumber as numeric)))));"' > $queryFolder$highFile"_"$previewFile; But in <'nodata' appear an error and I don't know how can I resolve it. The error is: ERROR: column "nodata" does not exist LINE 1: select preview from XT_FIJOS where preview <>nodata and id_r... Can anybody help me ? Thanks !! ^

    Read the article

  • Regarding PID Shell Script

    - by arav
    I am calling another shell script testarg.sh within my main script. the logfiles of testarg.sh are stored in $CUSTLOGS in the below format testarg.DDMONYY.PID.log example: testarg.09Jun10.21165.log In the main script after the testarg process gets completed i need to grep the log file for the text "ERROR" and "COMPLETED SUCCESSFULLY". How do i get the PID of the process and combine with DDMONYY for grepping. Also i need to check whether file exists before grepping $CUSTBIN/testarg.sh $CUSTBIN/testarg.sh rc=$? if [ $rc -ne 0 ]; then return $CODE_WARN fi

    Read the article

  • How to maipulate the shell output in php

    - by Mirage
    I am trying to write php script which does some shell functions like reporting. So i am starting with diskusage report I want in following format drive path ------------total-size --------free-space Nothing else My script is $output = shell_exec('df -h -T'); echo "<pre>$output</pre>"; and its ouput is like below Filesystem Type Size Used Avail Use% Mounted on /dev/sda6 ext3 92G 6.6G 81G 8% / none devtmpfs 3.9G 216K 3.9G 1% /dev none tmpfs 4.0G 176K 4.0G 1% /dev/shm none tmpfs 4.0G 1.1M 4.0G 1% /var/run none tmpfs 4.0G 0 4.0G 0% /var/lock none tmpfs 4.0G 0 4.0G 0% /lib/init/rw /dev/sdb1 ext3 459G 232G 204G 54% /media/Server /dev/sdb2 fuseblk 466G 254G 212G 55% /media/BACKUPS /dev/sda5 fuseblk 738G 243G 495G 33% /media/virtual_machines How can i convert that ouput into my forn\matted output

    Read the article

  • Shell script exiting the loop after calling another script

    - by Johnyy
    Hi Guys, I have a shell script s1 calling another script s2 in a loop. However s1 can not seem to continue the loop after s2 returns. Commenting out the line that calls s2 will enable the loop to continue. s2 does copy of one file, s1 checks conditions and copy several files using s2. Can anyone give a pointer what is going on here? ... while read line s2 param1 param2 param3 echo "copy done" done < $tempfile echo "out of loop" ... "copy done" is printed, so is "out of loop"

    Read the article

  • Shell script syntax error: unexpected end of line

    - by user1557674
    I wrote a simple shell script to check for the existence of a xml file and if it exists, then rename an old xml file to be backup and then move the new xml file to where the old xml file was stored. #!/bin/sh oldFile="/Documents/sampleFolder/sampleFile.xml" newFile="/Documents/sampleFile.xml" backupFileName="/Documents/sampleFolder/sampleFile2.backup" oldFileLocation="/Documents/sampleFolder" if [ -f "$newFile" ] ; then echo "File found" #Rename old file mv $oldFile $backupFileName #move new file to old file's location mv $newFile $oldFileLocation else echo "File not found, do nothing" fi However, every time I try to run the script, I get 4 command not found messages and a syntax error: unexpected end of file. Any suggestions on why I get these command not found errors or the unexpected end of file? I double checked that I closed all my double quotes, I have code highlight :) EDIT: output from running script: : command not found: : command not found: : command not found1: : command not found6: replaceXML.sh: line 26: syntax error: unexpected end of file

    Read the article

  • Access shell methods in controller? Cake PHP 1.3

    - by anonymous coward
    I wrote a shell method in CakePHP 1.3 that has a return value. I'd like to be able to access that method from within a controller, so that I can pass its return value into the View. I'm not sure how to access those methods appropriately from within the controller. Have I done it wrong? I could easily duplicate the code, but I'd like to "keep it DRY", and the actual functionality, I believe, doesn't belong with this particular controller - I just need it's return value in this particular view.

    Read the article

  • Making application menus on top of gnome shell

    - by GAP
    Is there a way to put gnome shell components (panel, message tray) to be appear below the popup menu's of other applications such as Java and Gtk Apps. The problem is when there are gtk apps which has tray icons the popup menu tends to appear below the message tray, this was bit ok now in 3.6 because the message tray hides soon as the icon is clicked. But the top bar is still a problem for large menus. When running eclipse with lot of options in the context menu the top most items including the scroll button are under top bar. Is there any thing i can change in the main.js or panel.js to get things below the popup menus ?

    Read the article

  • Run three shell script simultaneously

    - by user1419563
    I have three shell script which I am running as below- sh -x script1.sh sh -x script2.sh sh -x script3.sh So each script is executed sequentially one at a time after previous one finished executing. Problem Statement:- Is there any way I can execute all the three above scripts at same time from a single window? I just want to execute script1, script2, script3 at the same time. If you think of some cron JOB scheduling script1 at 3 AM, script2 at 3AM, script3 at 3AM (all three scripts at the same time, simultaneously). That's what I need, I need to execute all the three scripts simultaneously.

    Read the article

  • SWT Problem with MouseTrackListener and Shell

    - by Krt_Malta
    Hi! I'm developing an Eclipse plug-in and I have a problem which is reproduced in this small SWT application: public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Text text = new Text(shell, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY | SWT.V_SCROLL); text.setText("Hello"); shell.setLayout(new FillLayout()); shell.addMouseTrackListener(new MouseTrackListener() { public void mouseEnter(MouseEvent arg0) { System.out.println("mouseEnter"); } public void mouseExit(MouseEvent arg0) { System.out.println("mouseExit"); } public void mouseHover(MouseEvent arg0) { System.out.println("mouseHover"); } }); // Display the window shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); } As you can see I'm creating a shell and putting a Textbox inside it and putting it all across the shell. Then I attach a MouseTrackListener to the shell. The events don't fire (as in when I hover in the shell "mouseHover" is not printed etc). When I remove the Textbox the events fire. Can anyone tell me where the problem lies please? I don't want to attach a listener to the textbox but to the shell. I'll really appreciate the help because I've been trying to trace it for quite some time now. Thanks and regards, Krt_Malta

    Read the article

< Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >