Search Results

Search found 6758 results on 271 pages for 'shell exec'.

Page 42/271 | < Previous Page | 38 39 40 41 42 43 44 45 46 47 48 49  | Next Page >

  • C Minishell Command Expansion Printing Gibberish

    - by Optimus_Pwn
    I'm writing a unix minishell in C, and am at the point where I'm adding command expansion. What I mean by this is that I can nest commands in other commands, for example: $> echo hello $(echo world! ... $(echo and stuff)) hello world! ... and stuff I think I have it working mostly, however it isn't marking the end of the expanded string correctly, for example if I do: $> echo a $(echo b $(echo c)) a b c $> echo d $(echo e) d e c See it prints the c, even though I didn't ask it to. Here is my code: msh.c - http://pastebin.com/sd6DZYwB expand.c - http://pastebin.com/uLqvFGPw I have a more code, but there's a lot of it, and these are the parts that I'm having trouble with at the moment. I'll try to tell you the basic way I'm doing this. Main is in msh.c, here it gets a line of input from either the commandline or a shellfile, and then calls processline (char *line, int outFD, int waitFlag), where line is the line we just got, outFD is the file descriptor of the output file, and waitFlag tells us whether or not we should wait if we fork. When we call this from main we do it like this: processline (buffer, 1, 1); In processline, we allocate a new line: char expanded_line[EXPANDEDLEN]; We then call expand, in expand.c: expand(line, expanded_line, EXPANDEDLEN); In expand, we copy the characters literally from line to expanded_line until we find a $(, which then calls: static int expCmdOutput(char *orig, char *new, int *oldl_ind, int *newl_ind) orig is line, and new is expanded line. oldl_ind and newl_ind are the current positions in the line and expanded line, respectively. Then we pipe, and recursively call processline, passing it the nested command(for example, if we had "echo a $(echo b)", we would pass processline "echo b"). This is where I get confused, each time expand is called, is it allocating a new chunk of memory EXPANDEDLEN long? If so, this is bad because I'll run out of stack room really quickly(in the case of a hugely nested commandline input). In expand I insert a null character at the end of the expanded string, so why is it printing past it? If you guys need any more code, or explanations, just ask. Secondly, I put the code in pastebin because there's a ton of it, and in my experience people don't like it when I fill up several pages with code. Thanks.

    Read the article

  • Choppy window movement in Gnome 3.4 on Ubuntu 12.04

    - by mjrussell
    I have been using Gnome 3.2 since Ubuntu 11.10 was released and it has always been perfectly smooth and performed extremely well, much better than Unity. After doing a clean installation of Ubuntu 12.04, Gnome 3.4 performs less well. If just one window of a relatively simple application, such as Gnome Terminal, is opened and moved around, the movement is sometimes very choppy, but the rest of the time it's perfectly smooth. The times when it's choppy seem to be when part of the window goes off the bottom or right side of the screen. Also, if there are multiple windows open, it is almost always choppy. These facts suggest to me that it's something to do with the compositor. Unity works perfectly smoothly. Memory usage is only at about 500-600MB, out of 3GB, even with a few things open. The graphics card is the on-board Intel graphics on the Core i5 M450. Does anyone have any ideas what might be causing this problem? Thanks

    Read the article

  • how to rename and move files according to directory names?

    - by Shan
    I have bunch of directories containing the file with the same name. I want to move these files to another directory and at the same time renaming them with the directory name so that they are distinguished and are not over-written. EDIT: All the directories are in the same directory. Destination is one directory on the system which could be anything. We read directory and read file form it and rename it exactly as the directory name and put it to the destination. An important constraint is that the name of the file is given which will be in all of the directories. Directories might contain other files bit also the one which is given Thanks a lot

    Read the article

  • OpenSuSe look for Ubuntu

    - by DOOM
    Dont get me wrong, I have been using ubuntu and opensuse for about 2 years but, somehow I like using ubuntu. But it always bothers me about why OpenSuse "only looks" good?. And this is it. I have searched for it, but couldn't find a theme anywhere close to OpenSuse theme http://en.opensuse.org/images/0/04/Kde4-coverswitch.png Can someone help me to get a OpneSuse theme for UBUNTU 12.04 (GNOME_SHELL)

    Read the article

  • How to remove shells?

    - by MyNameIs...
    I installed few shells that I wanted to try out on Ubuntu 12.04, but none of them worked at all. It could be that I installed them all at the same time, meaning the OS didn't get a chance to work everything out, but either way, they didn't work. I would now like to remove them. The one's that I installed are Fluxbox, OpenBox, XFCE, and MATE. I installed them through the help of this site. Everything seemed to have been working properly until I actually tried to use the shells and nothing loaded at all. Except for Fluxbox, I think that one worked. I want to know of any way to repair or perhaps just remove the packages entirely. I might have already removed them because I did the apt-get remove command on all of them, but they were still in the list on the login screen.

    Read the article

  • How do I "alt-tab" between windows using Gnome 3?

    - by josmh
    All of the references I've found for Gnome 3 keyboard shortcuts list that alt+tab switches between applications and alt+` switches between windows (some actually say alt+~, but I think they're mistaken, and I've tried both anyway). Maybe that functionality works for Gnome 3 on Fedora or something, because no matter the key combo I try, nothing will switch between windows except for opening the alt+tab dialog and using arrow keys to navigate it (and at that point it's faster to just use a mouse..). How do I quickly switch between windows in Gnome 3?

    Read the article

  • Programmatically Getting Name of Front-most (currently running) application in Unity

    - by NHDaly
    I am trying to write a script that executes differently depending on the currently active program, and I am wondering if there is any way to find this programatically. For example, I come from the Mac world, and in Apple's Applescript you can do the following: set appPath to the path to the frontmost application set appName to the name of file appPath and that will give you the name of the currently running application. Is there anything similar that I can do in ubuntu-land? Thanks!

    Read the article

  • what other bash variables are available during execution such as $USER that can assist on my script?

    - by semi-newbie
    This is related to question 19245, in that one of the responders answered the question in an awesome way, and very VERY clear to any newbie. Now here is a question that i can't seem to figure. i wrote a script for starting the vmware firefox plugin (don't worry. i gave that up and now run vBox VERY happily. i left vmware for my servers :) ) I needed to start the plugin as sudo, but i also needed to pass an argument (password) to it, that happen to be the same. So, if my password was Hello123, the command would be: sudo ./myscript.sh hi other Hello123 running from command line, the script would ask for my sudo password and then run. i wanted to capture THAT password and pass it as well. i also wanted to run graphically, so i tried gksudo, and there is an option -p that returns the password for variable assignment. well, that was a nightmare, because i would still get prompted for the original sudo: see below Find UserName vUser=$USER Find password (and hopefully enable sudo) vP=gksudo -p -D somedescriptiontext echo Execute command gksudo ./myscript.sh hi $vUser $vP and i still get prompted twice. so my question is tri-fold: is there a variable i can use for the password, just like there is one for user, $USER? is there a different way i should be assigning the value resulting of the command i have in $vP? i am wondering if executing the way i have it, does it in an uninitiated session and not the current one, since i am getting some addtl warning type errors on some variables blah blah i tried using Zenity to just capture the text, but then of course, i couldn't pass that value to sudo, so i could only use as a parameter, which puts me back in 2 prompts. Thanksssssssssss!

    Read the article

  • How to execute a script as super user first checking the user and getting pass from askpass if not super user

    - by pahnin
    thers a similar question out there How can I determine whether a shellscript runs as root or not? I have the same doubt with different result Is it possible to, within the BASH script prior to everything being run, check if the script is being run as superuser, and if not, print a message saying You must be superuser to use this script, then subsequently get pass from the user using askpass or something like tht then execute the saem script as superuser?

    Read the article

  • Is Ubuntu's Gnome being updated?

    - by Swader
    What I'm wondering is this - is Ubuntu-native Gnome being updated? I'm asking because I notice a discrepancy - Unity had a problem before in the new mail indicator staying blue if you read the message directly in Thunderbird when it arrives instead of via clicking the indicator itself. This has been fixed in 12.04 from what I've noticed. But transitioning to Gnome returned this issue. Will this fix be applied to Gnome too, or has Gnome been abandoned in terms of staying up to date?

    Read the article

  • Why most use Cygwin and not Uwin?

    - by user287424
    Most academic researchers I know target just *nix, and rely on Cygwin to make their applications available on Windows. I have tried many of these projects and always found them too unstable for serious use when running on Cygwin. Uwin looks like a promising alternative to Cygwin. I haven't tried it yet, but I found several comments that it is faster and more stable. However, I haven't seen any use of Uwin to support running *nix apps on Windows. What are the social and/or technical reasons behind Uwin's lack of popularity?

    Read the article

  • Why "./" is used to run ".sh" scripts in Unix? [duplicate]

    - by user283502
    This question already has an answer here: Why do I need to type `./` before executing a program in the current directory? 10 answers I am executing a .sh script today. It is executed with prefix "./.sh,I am a bit confuse because it is also executed without ./.but why this is required to use ./ Could you please explain me that why ./ is used to run .sh scripts?

    Read the article

  • WPF : Access Application Resources when not referencing Shell from App.xaml

    - by CF_Maintainer
    I am beginner in WPF. My App.xaml looks like below app.xaml <Application x:Class="ContactManager.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Application.Resources> <Color x:Key="lightBlueColor">#FF145E9D</Color> <SolidColorBrush x:Key="lightBlueBrush" Color="{StaticResource lightBlueColor}" /> </Application.Resources> I do not set the startupuri since I want to a presenter first approach. I do the following in app.xaml.cs protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); var appPresenter = new ApplicationPresenter( new Shell(), new ContactRepository()); appPresenter.LaunchView(); } I have a usercontrol called "SearchBar.xaml" which references "lightBlueBrush" as a staticResource. When I try to open "Shell.xaml" in the designer it tells me : The "shell.xaml" cannot be loaded at design time because it says it could not create an instance of type "SearchBar.xaml". When I debugged the devenv.exe using another visual studio instance it tells me that it does not have access to the Brush I created in app.resources. If one is doing a Presenter first approach, how does one access resources? I had this working when the startupURI was "Shell.xaml" and the startup event was not present. Any clues/ideas/suggestions. I am just trying to understand. Everything works as expected when I run the application just not @ design time.

    Read the article

  • How to view shell commands used by eclipse "run configurations"

    - by gmale
    Given a "run configuration" in Eclipse, I want to print out the associated shell command that would be used to run it. For example: Right now, in Eclipse, if I click "play" it will run: mvn assembly:directory -Dmaven.test.skip=true I don't see that command, I just know that's what the IDE must run, at some point. However, some of the other run configurations are far more complex with long classpaths and virtual machine options and, frankly, sometimes I have no idea what the equivalent shell command would be (particularly when it comes to Flex). There must be some way to access the shell command that would be associated with a "Run Configuration" in Eclipse/Flex Builder. This information must be available, which leads me to believe someone has written a plugin to display it. Or maybe there's already an option built into Eclipse for accessing this. So is there a way to, essentially, convert an Eclipse run configuration into a shell command? (for context only: I'm asking because I'm writing a bash script that automates everything I do, during development--from populating the Database all the way to opening Firefox and clearing the cache before running the web app. So every command I run from the IDE needs to exist in the script. Some are tricky to figure out.)

    Read the article

  • basics of using cut awk grep and sed...

    - by Samantha
    Hello there, I'm trying to extract the year from this output : sam@sam-laptop:~/shell$ date Mon Feb 8 21:57:00 CET 2010 sam@sam-laptop:~/shell$ date | cut -d' ' -f7 2010 sam@sam-laptop:~/shell$ date | awk '{print $6}' 2010 Are there any other ways to get the same result ? using maybe grep, sed etc ? Merci !

    Read the article

  • Dynamic/runtime method creation (code generation) in Python

    - by Eli Bendersky
    Hello, I need to generate code for a method at runtime. It's important to be able to run arbitrary code and have a docstring. I came up with a solution combining exec and setattr, here's a dummy example: class Viking(object): def __init__(self): code = ''' def dynamo(self, arg): """ dynamo's a dynamic method! """ self.weight += 1 return arg * self.weight ''' self.weight = 50 d = {} exec code.strip() in d setattr(self.__class__, 'dynamo', d['dynamo']) if __name__ == "__main__": v = Viking() print v.dynamo(10) print v.dynamo(10) print v.dynamo.__doc__ Is there a better / safer / more idiomatic way of achieving the same result?

    Read the article

  • design for a wrapper around command-line utilities

    - by hatchetman82
    im trying to come up with a design for a wrapper for use when invoking command line utilities in java. the trouble with runtime.exec() is that you need to keep reading from the process' out and err streams or it hangs when it fills its buffers. this has led me to the following design: public class CommandLineInterface { private final Thread stdOutThread; private final Thread stdErrThread; private final OutputStreamWriter stdin; private final History history; public CommandLineInterface(String command) throws IOException { this.history = new History(); this.history.addEntry(new HistoryEntry(EntryTypeEnum.INPUT, command)); Process process = Runtime.getRuntime().exec(command); stdin = new OutputStreamWriter(process.getOutputStream()); stdOutThread = new Thread(new Leech(process.getInputStream(), history, EntryTypeEnum.OUTPUT)); stdOutThread.setDaemon(true); stdOutThread.start(); stdErrThread = new Thread(new Leech(process.getErrorStream(), history, EntryTypeEnum.ERROR)); stdErrThread.setDaemon(true); stdErrThread.start(); } public void write(String input) throws IOException { this.history.addEntry(new HistoryEntry(EntryTypeEnum.INPUT, input)); stdin.write(input); stdin.write("\n"); stdin.flush(); } } public class Leech implements Runnable{ private final InputStream stream; private final History history; private final EntryTypeEnum type; private volatile boolean alive = true; public Leech(InputStream stream, History history, EntryTypeEnum type) { this.stream = stream; this.history = history; this.type = type; } public void run() { BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); String line; try { while(alive) { line = reader.readLine(); if (line==null) break; history.addEntry(new HistoryEntry(type, line)); } } catch (Exception e) { e.printStackTrace(); } } } my issue is with the Leech class (used to "leech" the process' out and err streams and feed them into history - which acts like a log file) - on the one hand reading whole lines is nice and easy (and what im currently doing), but it means i miss the last line (usually the prompt line). i only see the prompt line when executing the next command (because there's no line break until that point). on the other hand, if i read characters myself, how can i tell when the process is "done" ? (either complete or waiting for input) has anyone tried something like waiting 100 millis since the last output from the process and declaring it "done" ? any better ideas on how i can implement a nice wrapper around things like runtime.exec("cmd.exe") ?

    Read the article

  • running Echo from Java

    - by ripper234
    I'm trying out the Runtime.exec() method to run a command line process. I wrote this sample code, which runs without problems but doesn't produce a file at c:\tmp.txt. String cmdLine = "echo foo > c:\\tmp.txt"; Runtime rt = Runtime.getRuntime(); Process pr = rt.exec(cmdLine); BufferedReader input = new BufferedReader( new InputStreamReader(pr.getInputStream())); String line; StringBuilder output = new StringBuilder(); while ((line = input.readLine()) != null) { output.append(line); } int exitVal = pr.waitFor(); logger.info(String.format("Ran command '%s', got exit code %d, output:\n%s", cmdLine, exitVal, output)); The output is INFO 21-04 20:02:03,024 - Ran command 'echo foo c:\tmp.txt', got exit code 0, output: foo c:\tmp.txt

    Read the article

  • Custom script in .screenrc

    - by benoror
    Hi. I made a script that spawns a remote shell or runs a local shell whether it's on the current machine or not: #!/bin/bash # By: benoror <[email protected]> # # spawns a remote shell or runs a local shell whether it's on the current machine or not # $1 = hostname if [ "$(hostname)" == "$1" ]; then bash else ssh "$1.local" fi For example, if I'm on server1: ./spawnshell.sh server1 -> runs bash ./spawnshell.sh server2 -> ssh to server2.local I want that script to run automatically in separate tabs in GNU Screen, but I can't make it run, my .screenrc: ... screen -t "@server1" 1 exec /home/benoror/scripts/spawnshell.sh server1 screen -t "@server2" 2 exec /home/benoror/scripts/spawnshell.sh server2 ... But it doesn't works, I've tried without 'exec', with -X option and a lot more. Any ideas ?

    Read the article

  • How do I set a property to the output of a command in msbuild/xbuild

    - by Nils
    In msbuild/xbuild I'd like to have a "libPath" property which can be ovveridden on the commandline using /p:libpath="/path/to/all/libs". But when this property is undefined I want to call pkg-config --retrieve-Path somePackage to get the current systems path. I thought like here I need the output of a command to be stored in a Property. The command always returns one line of output. I have tryied something like <PropertyGroup> <LibPath /> </PropertyGroup> <Task ....> <Exec Command="pkg-config --retrieve-Path somePackage" Condition="$(LibPath)' == ''"> <OutputTaskParameter="output" PropertyName="LibPath" /> </Exec> </Task> But that didn't work.

    Read the article

  • Globbing in `git checkout`

    - by yar
    Is there any way to implement globbing in git checkout? It would be great to be able to use git checkout re* or even to have tab completion in the shell. I'm using zsh, but an answer that is shell independent would be great. Note: I realize that this is kind of a pipe dream, so... if I needed to implement this myself, must it be done in the shell language itself, or could it be done in, say, Ruby?

    Read the article

  • Run .exe packaged in .jar

    - by user1471327
    I am trying to merge 2 programs I have made to one .jar file. One program is a .jar written in java and the second one is an .exe written in c++. I put both files to the new .jar, wrote this code but it didn't work. When this code was exported to .jar and executed neither of 2 files ran and I got error "no main manifest attribute, in merged.jar" in cmd. Though it worked perfectly when run in eclipse. public class main { public static void main(String[] args) { try { Runtime.getRuntime().exec("cmd /c project1.jar"); Runtime.getRuntime().exec("cmd /c project2.exe"); } catch(Exception exce) { /*handle exception*/ } } } Any idea how to fix this or is there another way to do it? I am new to java, so can't think of anything good. Maybe it would be possible to drop these files to a temporary location in windows and delete them after they're executed?

    Read the article

  • problem creating object "wscript.shell"

    - by sushant
    my script looks like: Dim WshShell, oExec Set WshShell = CreateObject("WScript.Shell") Set oExec = WshShell.Exec("cmd /c cd D:\d & D: & winzip32.exe -min -a D:\a") Do While oExec.Status = 0 WScript.Sleep 100 Loop WScript.Echo oExec.Status The idea was to use explorer to open these files. The problem I'm having though is on the line: Set WshShell = CreateObject("WScript.Shell") I keep getting the message ActiveX component can't create object: 'WScript.Shell' I'm totally confused because this exact same code runs fine if I write it in a .htm file. Why does my browser treat my .asp page differently than the .html file? How do i fix this problem?

    Read the article

  • Emacs shell output buffer height

    - by jimbo
    Hi , i have the following in my .emacs file(thanks to a SOer nikwin), which evaluates the current buffer content and displays the output in another buffer. (defun shell-compile () (interactive) (save-buffer) (shell-command (concat "python " (buffer-file-name)))) (add-hook 'python-mode-hook (lambda () (local-set-key (kbd "\C-c\C-c") 'shell-compile))) The problem is that the output window takes half the emacs screen. Is there any way to set the output windows's height to something smaller. I googled for 30mins or so and could not find anything that worked. Thanks in advance.

    Read the article

< Previous Page | 38 39 40 41 42 43 44 45 46 47 48 49  | Next Page >