shell

Alternative to Up Arrow + Enter to run previous command?

Sometimes I have to run a command many times in succession, for example to see if a service has started, and it becomes tedious to move my hands away from my normal typing position to press the Up Arrow and Enter keys repeatedly. Is there a way to run the previous command without the Up Arrow and Enter keys, perhaps with an elaborate she...

how to use a nested if and perform correct file checks in unix

Need some shell scripting help, especially with my if-then-else logic. I want to combine both conditions, but not sure if the file checks will work the same? Should I be doing something like a nested if?? My script uses the if statements to do file checks to see if they exist, then do something.. There is probably a better way to do fi...

Linux bash read output explanation

Hi, I would like to understand the values I get from read command in console. Are these outputs combinations of some keys? F2 ^[OQ F3 ^[OR F4 ^[OS ESC ^[ My problem is that I use special 128 keys keyboard that is programmed for specific software. I need to send these "keys" into this software using code below. Don't be confuse...

Combine two particular lines using sed

I have the following input file that you might recognize as a debian Packages file: Package: nimbox-apexer-sales Version: 1.0.0-201007241449 Architecture: i386 Maintainer: Ricardo Marimon <[email protected]> Installed-Size: 124 Depends: nimbox-apexer-root Filename: binary/nimbox-apexer-sales_1.0.0-201007241449_i386.deb Size: 68880 MD5...

Mysterious output for <cmd> followed by \ or `

Sometimes when I type a command in bash, I mistakenly type in the \ character at the end, as it is close to the Enter key. Whenever I do this, I get a prompt on the next line, like this: >_ The same output is produced when the ` character is used. What exactly does this \ do to the command? Are there other characters (besides \ an...

Python Script Fails To Run When Launched From Shell File, But Works When Launched From Terminal

If I launch the Google Code upload Python script from Terminal, it works as expected, but when I launch it using the code below in a Bourne Shell Script file, it fails with the error "close failed in file object destructor: Error in sys.excepthook: Original exception was:". #!/bin/sh BUILD_FOLDER="/Users/James/Documents/Xcode Projects/U...

problems combining files using unix cat and zcat in shell script

I've got a problem with my shell script. I am basically trying to create a new log file from (2) files using unix (zcat, cat) commands FileA = gzipped logfile (.gz) FileB = non-gzipped log file (.log) FileC = new file from FileA:FileB My problem is with FileC. For example: FileA has timestamp data from Aug19-Sept3 FileB has timest...

Replacing tilde with $HOME in simple shell

Hello. I am writing a simple Unix shell in C. Here's what I have so far. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> int main() { char x[256], y[256], z[256]; while (1) { getcwd(y, sizeof(y)); printf("%s$ ", y); fgets(x, sizeof(x), stdin); if (x[0] == 'c' && x[1...

Shell script : How to cut part of a string

Hello, I have following string â â³ eGalax Inc. USB TouchController id=9 [slave pointer (2)] â â³ eGalax Inc. USB TouchController id=10 [slave pointer (2)] and would like to get the list of id ? How this can be done using sed or something else ? Regards, Levon ...

techniques for parsing interactive input(like a shell)?

I'm working on a program that can be used directly from the command line with options and input files, or entirely interactively like a shell. For the initial execution I'm using GNU's Getopt to parse the command line options. When being used on a file I'm using Flex and Bison. This simplifies the parsing greatly since the grammar is ve...

How to get the contents of a webpage in a shell variable ?

In Linux how can I fetch an URL and get its contents in a variable in shell script? ...

RegEx in bash-script (for-loop)

I want to parse the arguments given to a shell script by using a for-loop. Now, assuming I have 3 arguments, something like for i in $1 $2 $3 should do the job, but I cannot predict the number of arguments, so I wanted use an RegEx for the range and $# as the number of the last argument. I don't know how to use these RegEx' in a for-loop...

Call a shell script in java?

Hey, is it possible to call a shellscript or the shellcode in a java class? My Code (in a static method): Runtime rtime = Runtime.getRuntime(); Process child = rtime.exec("/bin/bash"); BufferedWriter outCommand = new BufferedWriter(new OutputStreamWriter(child.getOutputStream())); outCommand.write("streamer -c /dev/video0 -b32 -o test...

Executing shell commands using PHP, e.g. shell_exec() etc., on a remote host?

Is it possible to execute shell commands on a remote computer (not localhost)? For instance things like $output = shell_exec("unzip filename.zip"); You can assume that you have the login credentials of a user account on the remote machine, as well as the remote root username, password, and cpanel remote access key. ...

Hook up into another Terminal process?

I've got two terminal instances/processes opened with different PID. Is it possible to from one of them, hook up into the other so when I type something and it outputs something, then the other terminal will see the output too (maybe the input too if possible?). Just like cloning the terminals. I want this because then I can hook up s...

Shell script with whitespace in path executes differently depending on directory

I have made a script to open Spotify with wine: #!/bin/bash DIR="/home/jorgsk/.wine/drive_c/Program Files/Spotify/" cd "$DIR" wine spotify.exe 2>/dev/null I'm passing "$DIR" to cd with quotes because of the whitespace in "Program Files"; if I don't have the quotes "/home/jorgsk/.wine/drive_c/Programs" will be considered as the argumen...

Building python Shell

I have some small python 2.6 scripts built.... Now, I would like run them as seperate processes within a python shell. Each as a seperate process. If one fails to run maybe with its timer, I would like others to continue without killing all scripts. Should I do this as singleton gui's or combine them into bigger launch pad. My perfere...

How do I set a default message in Office Communicator when opening a new conversation with a URI?

I'm using the Office Communicator Shell Integration to launch a new conversation with a resource using a URI to launch the conversation. However I want to inject a default message that the user just needs to click enter to send. I want to accomplish the same that the mailto: shell integration provides, but is that possible using a URI f...

How to preserve double quotes in $@ in a shell script?

Let's say I have a really simple shell script 'foo': #!/bin/sh echo $@ If I invoke it like so: foo 1 2 3 It happily prints: 1 2 3 However, let's say one of my arguments is double-quote enclosed and contains whitespace: foo 1 "this arg has whitespace" 3 foo happily prints: 1 this arg has whitespace 3 The double-...

linux environmental variable diff

I have two Linux xterms with "almost" the same setup. One setup works and the other doesn't for my application. Is there a tool that can help me figure out which particular environment variable is causing the failure? (A visual diff) Currently - I do env > a1 env > a2 in the 2 xterms and do a diff on them. But would like to know if...