Search Results

Search found 6936 results on 278 pages for 'shell scripting'.

Page 22/278 | < Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >

  • Printing Stdout In Command Line App Without Overwriting Pending User Input

    - by Chris S
    In a basic Unix-shell app, how would you print to stdout without disturbing any pending user input. e.g. Below is a simple Python app that echos user input. A thread running in the background prints a counter every 1 second. import threading, time class MyThread( threading.Thread ): running = False def run(self): self.running = True i = 0 while self.running: i += 1 time.sleep(1) print i t = MyThread() t.daemon = True t.start() try: while 1: inp = raw_input('command> ') print inp finally: t.running = False Note how the thread mangles the displayed user input as they type it (e.g. hell1o wo2rld3). How would you work around that, so that the shell writes a new line while preserving the line the user's currently typing on?

    Read the article

  • SSH login with expect(1). How to exit expect and remain in SSH?

    - by Koroviev
    So I wanted to automate my SSH logins. The host I'm with doesn't allow key authentication on this server, so I had to be more inventive. I don't know much about shell scripting, but some research showed me the command 'expect' and some scripts using it for exactly this purpose. I set up a script and ran it, it worked perfectly to login. #!/usr/bin/env expect -f set password "my_password" match_max 1000 spawn ssh -p 2222 "my_username"@11.22.11.22 expect "*?assword:*" send -- "$password\r" send -- "\r" expect eof Initially, it runs as it should. Last login: Wed May 12 21:07:52 on ttys002 esther:~ user$ expect expect-test.exp spawn ssh -p 2222 [email protected] [email protected]'s password: Last login: Wed May 12 15:44:43 2010 from 20.10.20.10 -jailshell-3.2$ But that's where the success ends. Commands do not work, but hitting enter just makes a new line. Arrow keys and other non-alphanumeric keys produce symbols like '^[[C', '^[[A', '^[OQ' etc.[1] No other prompt appears except the two initially created by the expect script. Any ignored commands will be executed by my local shell once expect times out. An example: -jailshell-3.2$ whoami ls pwd hostname (...time passes, expect times out...) esther:~ user$ whoami user esther:~ ciaran$ ls Books Documents Movies Public Code Downloads Music Sites Desktop Library Pictures expect-test.exp esther:~ ciaran$ pwd /Users/ciaran esther:~ ciaran$ hostname esther.local As I said, I have no shell scripting experience, but I think it's being caused because I'm still "inside of" expect, but not "inside of" SSH. Is there any way to terminate expect once I've logged in, and have it hand over the SSH session to me? I've tried commands like 'close' and 'exit', after " send -- "\r" ". Yeah, they do what I want and expect dies, but it vindictively takes the SSH session down with it, leaving me back where I started. What I really need is for expect to do its job and terminate, leaving the SSH session back in my hands as if I did it manually. All help is appreciated, thanks. [1] I know there's a name for this, but I don't know what it is. And this is one of those frightening things which can't be googled, because the punctuation characters are ignored. As a side question, what's the story here?

    Read the article

  • script unable to find directories/files when running from qsub cluster script

    - by user248237
    I'm calling several unix commands and python on a python script from a qsub shell script, meant to run on a cluster. The trouble is that when the script executes, something seems to go awry in the shell, so that directories and files that exist are not found. For example, in the .out output files of qsub I see the following errors: cd: /valid/dir/name: No such file or directory python valid/script/name.py python: can't open file 'valid/script/name.py': [Errno 2] No such file or directory so the script cannot cd into a dir that definitely exist. Similarly, calling python on a python script that definitely exists yields an error. any idea what might be going wrong here, or how I could try to debug this? thanks very much.

    Read the article

  • Auto SSH and execute script

    - by rohanbk
    I have roughly 12 computers that each have the same script on them. This script merely pings all the other machines, and prints out whether the machine is "reachable" or "unreachable". However, it is inefficient to login to each machine manually using ssh to execute this script. Suppose I'm logged into node 1. Is there any way to for me to login to node 2-12 automatically using SSH, execute the ping script, pipe the results to a file, logout and proceed to the next machine? Some kind of bash shell script? I'm afraid I'm at a loss here since I haven't had experience with shell-scripting before.

    Read the article

  • Accessing variable from ARGV

    - by snaken
    I'm writing a cPanel postwwwact script, if you're not familiar with the script its run after a new account is created. it relies on the user account variable being passed to the script which i then use for various things (creating databases etc). However, I can't seem to find the right way to access the variable i want. I'm not that good with shell scripts so i'd appreciate some advice. I had read somewhere that the value i wanted would be included in $ARGV{'user'} but this simply gives "root" as opposed to the value i need. I've tried looping through all the arguments (list of arguments here) like this: #!/bin/sh for var do touch /root/testvars/$var done and the value i want is in there, i'm just not sure how to accurately target it. There's info here on doing this with PHP or Perl but i have to do this as a shell script. EDIT Ideally i would like to be able to call the variable by something other than $1 or $2 etc as this would create issues if an argument is added or removed Any ideas?

    Read the article

  • GET command is giving two kinds of ouput,why???

    - by developer
    iam using GET command to get the content of a page.When i write the same command on shell prompt it gives correct result but when i use that in PHP file then sometimes its giving correct result but sometimes it gives only half of the content i.e. end-half portion only. Iam using following command in shell script :- GET http://www.abc.com/ -H "Referer:http://www.abcd.com/" and following in PHP file :- $data=exec('GET http://www.abc.com/ -H "Referer:http://www.abcd.com/"'); echo $data; Now please tell why this command is not giving full content of the page when im using it in php file.

    Read the article

  • PHP system() help

    - by sea_1987
    Hello, I have this shell script #!/bin/sh ############################################################# # Example startup script for the SecureTrading Xpay4 client # # Install Xpay4 into /usr/local/xpay4 # # To run this script automatically at startup, place the # # following line at the end of the bootup script. # # eg. for RedHat linux: /etc/rc.d/rc.local # # # # /usr/local/xpay4/xpay4.sh # ############################################################# # Configuration options # Path to java executable JAVAPATH=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home ########## Do not alter anything below this line ########## echo "Starting Xpay4. Please ensure the Xpay4 client is not already running" $JAVAPATH/java -jar /usr/local/xpay4/Xpay4.jar /usr/local/xpay4/xpay4.ini & And I am trying to run it using, system("/x/sh/shell.sh"); I am doing this when a user navigates to a certain page on my site, however I am getting just a white blank screen is there a way to error check with system(), I am currently using error_reporting(E_ALL | E_STRCIT) and that is applied site wide

    Read the article

  • iTorque for a simple arcade game

    - by Herfus
    I have a basic understanding of programming, but I am no programmer. I've had a couple of a semesters with java programming, so we're talking pretty basic here. I have some scripting experience with game editors where I've created a few (simple) encounters, boss AI, abilities, events and so on. I've mostly done level design with UDK, Source and several other toolsets for a few years now, but I'd like to divert some of the focus to iphone-development. I've participated in a few development projects (source, udk, daot) where I've had a variety of roles (yet never beyond simple scripting). I have just finished prototyping an Iphone game (using game maker) and begun a bit more precise planning on what I'll have to do for the real version. The game is fairly simple, perhaps the best comparison in scope and complexity would be Doodlejump for iPhone. The reason I created the prototype was not just to answer a few questions about the gameplay, but to get some insight into what kind of problems I might face when trying to develop the real thing. I've been looking for engines that I can use for this. iTorque looks, so far, like the best option with a scripting language and WYSIWYG-editor. However the price is fairly steep and I'd like to prepare myself as much as possible before jumping into this, which is why I'm going to ask a few questions here. What kind of difficulties do you think I might run into, considering what you've read so far? Not just with torque, but development in general. I'm making this question mostly to have someone to reality check me. I usually achieve to do what I'm trying to do with scripting, but something tells me there's a very big difference between scripting an AI or an event and creating game logic. Will it be too much of a leap? Just how simple is it to use the Torque scripting language? Obviously I don't expect to be prepared, I expect it to be a learning process. However, I'd still like to be at least a bit confident on the time I'll have to dedicate to this first.

    Read the article

  • Scriptable user-interfaces/frameworks for automated UI testing

    - by AareP
    I'm planning on using scripting for automated UI testing. Main application is written in c#, and I want it to be scriptable, so I can do everything end-user can do, but programmatically. What do you think of software that provides an interface for scripting, like VBA macros in Excel? Can this be future of all programming, big and small? What is the best way to build such an interface for your own application, dll-based or by parsing own scripting language?

    Read the article

  • typeset: not found error when executing shell script. Am I missing a package or something?

    - by user11045
    Hi, below is the error and corresponding script lines: spec@Lucifer:~/Documents/seagull.svn.LINUX$ ./build.ksh ./build.ksh: 36: typeset: not found ./build.ksh: 39: typeset: not found ./build.ksh: 44: function: not found Command line syntax of - options -exec : mode used for compilation (default RELEASE) -target : target used for compilation (default all) -help : display the command line syntax ./build.ksh: 52: function: not found ERROR: spec@Lucifer:~/Documents/seagull.svn.LINUX$ Script Init of variables BUILD_TARGET=${BUILD_DEFAULT_TARGET} BUILD_EXEC=${BUILD_DEFAULT_EXEC} typeset -u BUILD_OS=uname -s | tr '-' '_' | tr '.' '_' | tr '/' '_' BUILD_CODE_DIRECTORY=code BUILD_DIRECTORY=pwd typeset -u BUILD_ARCH=uname -m | tr '-' '_' | tr '.' '_' | tr '/' '_' BUILD_VERSION_FILE=build.conf BUILD_DIST_MODE=0 BUILD_FORCE_MODE=0

    Read the article

  • Enabling a multi display desktop completely broke Gnome Shell. Help?

    - by Chintan Parikh
    I've been trying to get my dual desktops working on Ubuntu for a while. I previously had them as one large desktop, but that was incredibly slow for some reason. I tried to switch them to multi display desktop on the AMD Catalyst Control Center. Here's what I get after restarting and logging in: http://i.imgur.com/SEjgU.png I'm running an AMD Quad Core A6, AMD Radeon 6540G2 GPU, 16GB Ram. Ubuntu 12.04 Any ideas?

    Read the article

  • How to resolve symbolic links in a shell script

    - by Greg Hewgill
    Given an absolute or relative path (in a Unix-like system), I would like to determine the full path of the target after resolving any intermediate symlinks. Bonus points for also resolving ~username notation at the same time. If the target is a directory, it might be possible to chdir() into the directory and then call getcwd(), but I really want to do this from a shell script rather than writing a C helper. Unfortunately, shells have a tendency to try to hide the existence of symlinks from the user (this is bash on OS X): $ ls -ld foo bar drwxr-xr-x 2 greg greg 68 Aug 11 22:36 bar lrwxr-xr-x 1 greg greg 3 Aug 11 22:36 foo -> bar $ cd foo $ pwd /Users/greg/tmp/foo $ What I want is a function resolve() such that when executed from the tmp directory in the above example, resolve("foo") == "/Users/greg/tmp/bar".

    Read the article

  • flush output in Bourne Shell

    - by n-alexander
    I use echo in Upstart scripts to log things: script echo "main: some data" >> log end script post-start script echo "post-start: another data" >> log end script Now these two run in parallel, so in the logs I often see: main: post-start: some data another data This is not critical, so I won't employ proper synching, but thought I'd turn auto flush ON to at least reduce this effect. Is there an easy way to do that? Update: yes, flushing will not properly fix it, but I've seen it help such situations to some degree, and this is all I need in this case. It's just that I don't know how to do it in Shell

    Read the article

  • Shell access to files created by Apache user in PHP

    - by Alexandru Trandafir Catalin
    My website creates files with owner apache:apache when uploading a file, like this: drwxr-xr-x 2 apache apache 4096 Aug 28 14:07 . drwxr-xr-x 9118 apache apache 233472 Aug 28 14:07 .. -rw-r--r-- 1 apache apache 41550 Aug 28 14:07 468075_large.jpg -rw-r--r-- 1 apache apache 26532 Aug 28 14:07 468075_medium.jpg -rw-r--r-- 1 apache apache 50881 Aug 28 14:07 468075_original.jpg -rw-r--r-- 1 apache apache 4316 Aug 28 14:07 468075_small.jpg Now I am trying to create a file inside the same folder with the user that owns that domain in Plesk and I get permission denied. How can I have both apache and shell user with permissions over that files? Thanks.

    Read the article

  • expr non-numeric argument shell script

    - by Kimi
    The below check is not working : expr non-numeric argument shell script. Always it is going to else. Please tell me what is the mistake. Earlier I was no using while so the same thing was woring fine now suddenly when I did put it in the while loop it is no working. echo "`${BOLD}` ***** Checking Memory Utilization User*****`${UNBOLD}`" echo "===================================================" IFS='|' cat configMachineDetails.txt | grep -v "^#" | while read MachineType UserName MachineName do export MEMORY_USAGE1=`ssh -f -T ${UserName}@${MachineName} prstat -t -s rss 1 2 | tr '%' ' '| awk '$5>5.0'` export LEN=`echo "$MEMORY_USAGE1"|wc -l` export CNPROC=`echo "$MEMORY_USAGE1"|grep "NPROC"|wc -l` export CTotal=`echo "$MEMORY_USAGE1"|grep "Total"|wc -l` **if [ $LEN = `expr $CNPROC + $CTotal` ] then echo "`${BOLD}`**************All usages are normal !!!!!! *************`${UNBOLD}`" else echo "`${BOLD}`**** Memory(%) is more than 5% in MachineType $MachineType UserName $UserName MachineName $MachineName *******`${UNBOLD}`" echo "====================================================" echo "$MEMORY_USAGE1" fi** done

    Read the article

  • android : how to run a shell command from within code

    - by ee3509
    I am trying to execute a command from within my code, the command is "echo 125 /sys/devices/platform/flashlight.0/leds/flashlight/brightness" and I can run it without problems from adb shell I am using Runtime class to execute it : Runtime.getRuntime().exec("echo 125 > /sys/devices/platform/flashlight.0/leds/flashlight/brightness"); However I get a permissions error since I am not supposed to access the sys directory. I have also tried to place the command in a String[] just in case spaces caused a problem but it didn't make much differense. Does anyone know any workaround for this ?

    Read the article

  • Cheat sheet exhibiting bash shell stdout/stderr redirection behavior

    - by SetJmp
    Is there a good cheat sheet demonstrating the many uses of BASH shell redirection? I would love to give such a thing to my students. Some examples I'd like to see covered: cmd > output_file.txt #redirect stdout to output_file.txt cmd 2> output_file.txt #redirect stderr to output_file.txt cmd >& outpout_file.txt #redirect both stderr and stdout to output_file.txt cmd1 | cmd2 #pipe cmd1 stdout to cmd2's stdin cmd1 2>&1 | cmd2 #pipe cmd1 stdout and stderr to cmd2's stdin cmd1 | tee result.txt #print cmd1's stdout to screen and also write to result.txt cmd1 2>&1 | tee result.txt #print stdout,stderr to screen while writing to result.txt (or we could just make this a community wiki and enumerate such things here) Thanks! SetJmp

    Read the article

  • get a list of function names in a shell script

    - by n-alexander
    I have a Bourne Shell script that has several functions in it, and allows to be called in the following way: my.sh <func_name> <param1> <param2> Inside func_name() will be called with param1 and param2. I want to create a "help" function that would just list all available functions, even without parameters. The question: how do I get a list of all function names in a script from inside the script? I'd like to avoid having to parse it and look for function patterns. Too easy to get wrong. Thanks, Alex

    Read the article

  • How to stop java application using a shell script

    - by Fernando Moyano
    I have a shell script, which is run under a opensuse linux, that starts a java application (under a jar), the script is: #!/bin/sh #export JAVA_HOME=/usr/local/java #PATH=/usr/local/java/bin:${PATH} #---------------------------------# # dynamically build the classpath # #---------------------------------# THE_CLASSPATH= for i in `ls ./lib/*.jar` do THE_CLASSPATH=${THE_CLASSPATH}:${i} done #---------------------------# # run the application # #---------------------------# java -server -Xms512M -Xmx1G -cp ".:${THE_CLASSPATH}" com.package.MyApp > myApp.out 2>&0 & This script is working fine. Now, what I want, is to write a script to kill gracefully this app, something that allows me to kill it with the -15 argument from Linux kill command. The problem, is that there will be many java applications running on this server, so I need to specifically kill this one. Any help? Thanks in advance, Fernando

    Read the article

  • Modify shell script to monitor/ping multiple ip addresses

    - by Alex
    Alright so I need to constantly monitor multiple routers and computers, to make sure they remain online. I have found a great script here that will notify me via growl(so i can get instant notifications on my phone) if a single ip cannot be pinged. I have been attempting to modify the script to ping multiple addresses, with little luck. I'm having trouble trying to figure out how to ping a down server while the script keeps watching the online servers. any help would be greatly appreciated. I haven't done much shell scripting so this is quite new to me. Thanks #!/bin/sh #Growl my Router alive! #2010 by zionthelion73 [at] gmail . com #use it for free #redistribute or modify but keep these comments #not for commercial purposes iconpath="/path/to/router/icon/file/internet.png" # path must be absolute or in "./path" form but relative to growlnotify position # document icon is used, not document content # Put the IP address of your router here localip=192.168.1.1 clear echo 'Router avaiability notification with Growl' #variable avaiable=false com="################" #comment prefix for logging porpouse while true; do if $avaiable then echo "$com 1) $localip avaiable $com" echo "1" while ping -c 1 -t 2 $localip do sleep 5 done growlnotify -s -I $iconpath -m "$localip is offline" avaiable=false else echo "$com 2) $localip not avaiable $com" #try to ping the router untill it come back and notify it while !(ping -c 1 -t 2 $localip) do echo "$com trying.... $com" sleep 5 done echo "$com found $localip $com" growlnotify -s -I $iconpath -m "$localip is online" avaiable=true fi sleep 5 done

    Read the article

  • Optimize grep, awk and sed shell stuff

    - by kockiren
    I try to sum the traffic of diffrent ports in the logfiles from "IPCop" so i write and command for my shell, but i think its possible to optimize the command. First a Line from my Logfile: 01/00:03:16 kernel INPUT IN=eth1 OUT= MAC=xxx SRC=xxx DST=xxx LEN=40 TOS=0x00 PREC=0x00 TTL=98 ID=256 PROTO=TCP SPT=47438 DPT=1433 WINDOW=16384 RES=0x00 SYN URGP=0 Now i grep with following Command the sum of all lengths who contains port 1433 grep 1433 log.dat|awk '{for(i=1;i<=10;i++)if($i ~ /LEN/)print $i};'|sed 's/LEN=//g;'|awk '{sum+=$1}END{print sum}' The for loop i need because the LEN-col is not on same position at all time. Any suggestion for optimizing this command? Regards Rene

    Read the article

  • Recursive FTP directory listing in shell/bash with a single session (using cURL or ftp)

    - by Timo
    I am writing a little shellscript that needs to go through all folders and files on an ftp server (recursively). So far everything works fine using cURL - but it's pretty slow, becuase cURL starts a new session for every command. So for 500 directories, cURL preforms 500 logins. Does anybody know, whether I can stay logged in using cURL (this would be my favourite solution) or how I can use ftp with only one session in a shell script? I know how to execute a set of ftp commands and retrieve the response, but for the recursive listing, it has to be a little more dynamic... Thanks for your help!

    Read the article

  • Shell script to process files

    - by Harish
    I need to write a Shell Script to process a huge folder of nearly 20 levels.I have to process each and every file and check which files contain lines like select insert update When I mean line it should take the line till I find a semicolon in that file. I should get a result like this C:/test.java select * from dual C:/test.java select * from test C:/test1.java select * from tester C:/test1.java select * from dual and so on.Right now I have a script to read all the files #!bin/ksh FILE=<FILEPATH to be traversed> TEMPFILE=<Location of Temp file> cd $FILE for f in `find . ! -type d`; do cat $FILE/addedText.txt>>$TEMPFILE/newFile.txt cat $f>>$TEMPFILE/newFile.txt rm $f cat $TEMPFILE/newFile.txt>>$f rm $TEMPFILE/newFile.txt done I have very little knowledge of awk and sed to proceed further in reading each file and achieve what I want to.Can anyone help me in this

    Read the article

  • 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

< Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >