Any tips on Controlling interactive bash shell on Cygwin via Java process?

Ideally, I'd like to be able to control an interactive bash shell on Cygwin from a Java process. But for starters, I want to do 'ls > /cygdrive/c/fred.txt'. The little program to do this, below, doesn't work. It simply runs without error.
Any ideas? And also, any tips on doing a fully interactive shell?
--> Java program to test simple command:
package com.treelogic_swe.real_estate_explorer.utils;
import java.io.File;
import java.io.InputStream;
* Quick and dirty test of Java to Cygwin bash shell process control.
* Thanks to [email protected]
* re: http://groups.google.com/group/comp.lang.java.help/browse_thread/thread/914403fbdd1de127/40363d2e7cbae823?lnk=st&q=cygwin+shell+java+process+runtime&rnum=1&hl=en#40363d2e7cbae823
public class RunSystemCommand {   
    public static void main(String args[]) throws Throwable {
     // System command to run
     String cmd = "ls > /cygdrive/c/fred.txt";
        String [] sysArgs = { };
     // Set the working directory for the OS command processor
     File workDir = new File( "c:/cygwin/bin" );
     Process bash = Runtime.getRuntime().exec( cmd, sysArgs, workDir );
     InputStream bashIn = bash.getInputStream();
     while( bashIn.read() != -1 ); // Added, as otherwise the ls hangs.
     bash.waitFor();
}

Ideally, I'd like to be able to control an
interactive bash shell on Cygwin
What do you mean by this? Do you just want to start a bash shell, and have it's input and output come from and go to your Java program?
Please be specific about what you want, as there are a couple of interpretations for what you said. You need to understand the differences and relationships among terminals, shells, shell builtins, and executables.
You'll want to read this:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
from a Java
process. But for starters, I want to do 'ls >
/cygdrive/c/fred.txt'. The little program to do
this, below, doesn't work. It simply runs without
error.
, <, |, and others are specific to the shell. When you're in a terminal, and you type ls > /tmp/zzz, it's the bash shell that interprets the >. Cygwin doesn't know anything about it. ls doesn't know anything about it.So if you want to to that, the command you'd execute from Java is not ls, but bash (or some other shell). You'd then tell bash to execute the rest. I'm not sure what the command line arg is for bash to tell it the rest of the command line args are a command that bash should interpret and execute. I think it might be -c like it is for zsh. So you'd need to do something like Runtie.getRuntime().exec("bash -c 'ls > /tmp/zzz'");

Similar Messages

  • Bash shell does not recognise 'java', 'javac' commands (Linux command line)

    i' ve used javac and java compile & execute commands to build the same application on the DOS command line with Windows - no problem.
    But when I try to compile the same file on the command line under Linux Redhat (7.1) using Bash shell i get <bash: javac: command not found> and <bash: java: command not found>.
    In both cases I'm using j2sdk1.4.2 downloaded from java.sun.com for Windows & Linux respectively.
    I make sure I have both the javac and the file I want to compile in the same directory ../j2sdk1.4.2/bin for both the Windows and the Linux applications.
    Is there something I need to do to get bash to recognise javac, java etc? Is there a different setup procedure?
    Any angles on this are much appreciated ..

    Have you tried these correctly..
    Set the CLASSPATH environment variable to include whichever directories you like, eg (on bash) type:
    export CLASSPATH=$CLASSPATH:.:<your java dirs>
    To make java easier to run, put the directory in which it is installed into your path:
    export JAVA_HOME=<where you installed java>
    Then do
    export PATH=$PATH:$JAVA_HOME/bin
    verify it has worked by simply typing
    java
    You can put all of these commands into the .*rc file for your shell, so that they are executed every time you open the shell. So if you are using bash you can put them into ~/.bashrc
    Read up setting the PATH and CLASSPATH for more info.
    This shall resolve the issue .

  • Is there any way to control an iPod with a lock via USB cable?

    I have an iPod touch 4th generation, but I dropped it. The touchscreen no longer works, which is most likely a hardware error (I've tried resetting it). I plan to get a new device, but before that, I would like to be able to unlock it to access certain files and transfer codes inside. I know the lock password to my iPod; is there any way I could control it with my computer?
    Thanks.

    You may be able to get some info from the restored/erased iPod by:
    How to perform iPad recovery for photos, videos
    Wondershare Dr.Fone for iOS: iPhone Data Recovery - Wondershare Official     
    http://www.amacsoft.com/ipod-data-recovery.html
    iPod recovery software to restore lost music files      
    http://www.pcrecoverytools.com/ipod-data-recovery.html
    -iPod touch Deleted Photo Recovery Tips You Should Know

  • How do I put some kind of parental controls on my ipad 2? My 7 year old daughter just purchased, without my permission, $275 worth of in app purchases in Mall Stars game.  Any tips on how to reverse that purchase?

    How do I put some kind of parental controls on my ipad 2? My 7 year old daughter just purchased, without my permission, $275 worth of in app purchases in Mall Stars game.  Any tips on how to reverse that purchase?

    You can also contact itunes support and ask for a refund.
    expresslane.apple.com
    https://expresslane.apple.com/Issues.action

  • Is there any plan to create a HTML5 shell for flash player apps & interactive elements?

    Is there any plan to create a HTML5 shell for flash player apps and elements? The canvas option is very limited and many apps & old, interactive flash elements no longer work on most mobile devices. 

    HTML5 is the "anti-flash", so to speak. It requires no plug-ins. HTML5 is MP4 which is QuickTime video. That's the "shell" for it.
    Steve Jobs said in 2006, when iOS was first released, that "playing Flash content is processor consumptive and drains batteries in mobile devices, reducing their life." That's why Apple iOS devices have never been compatible with Flash, and also why Android dropped support for the technology in June of 2012.
    Android has "Dolphin" and "Puffin" browsers, which render Flash content (video and animations) "server side" to reduce the load on mobile devices running Android. Likewise, Apple has "SkyFire" which works the same way, but is designed specifically for iOS.

  • Any speculation around Bash "Shell shock" impact on VMware products?

    According to VMware investigating bash command injection vulnerability aka Shell Shock (CVE-2014-6271, CVE-2014-7169) | VMware Securi…, VMware is investigating the impacts of the Bash security vulnerability on VMware products.
    What do you think about the possible impact on ESXi hosts? Vulnerable to remote code execution or not?

    Does anybody know if the vShield Manager 5.1.4.1912202 is affected by shellshock? Thanks!!
    While not mentioning vShield Manager in particular, the KB article lists "vCloud Networking and Security 5.x (aka VMware Shield 5.x)" which the vShield Manager virtual appliance is a part of.
    Since the vShield Manager virtual appliance runs a full GNU/Linux OS underneath, I'm 99% certain it has a bash and is thus affected as well, like all the other virtual appliances. In fact, I'm not aware of any VMware virtual appliance that don't have a bash shell (feel free to correct me if I'm wrong).
    It seems like VMware is doing the proper thing and disabling parsing in bash altogether.
    Probably requires a lot more QA testing, but mitigates future parser bugs that are most likely coming.
    http://www.openwall.com/lists/oss-security/2014/09/29/43
    That's quite interesting.
    This raises the general issue of virtual appliances and patching once again. The GNU/Linux OS running in pretty much all appliances is just a customized version of another popular distribution (majorly SuSe in VMware's VAs), so in theory you could just update with the distributions default packages instead of having to wait for vendors to publish it's "certified" updates.
    I completely agree that QA is important and it can be problematic for certain packages like java, webserver or database software and depending libraries. But updates to more "generic" applications like bash or openssl (heartbleed), which only fix a very certain code area, shouldn't cause any issues in the applications.
    Given the severity of bugs like Shellshock and Heartbleed, there might be limited patience in some environments with waiting for vendors re-packing fixes that are released since some time.
    That "updating" a virtual appliance sometimes means "deploy a new VA from scratch and migrate data" doesn't help in that regard either.

  • How to invoke BASH shell and execute a command in that shell in Windows 98

    Hello, I have a problem and if somebody will help me, I will be very glad. Thank you.
    I am using BASH shell on Windows 98 OS by means of CYGWIN. And I want to invoke this BASH shell and execute a preprogrammed command in the shell (./scan fileName.txt) from a JAVA program. But so far, I am not sucessful. I can not read or write anything from / to BASH shell. It either blocks and freezes (When I use waitFor( ) ) or appears and disappears without executing scan command (When I do not use waitFor( ) ). My code is like this:
    // This method is used for compiling a file.
    // It invokes BASH shell and executes "./scan fileName.txt" command
    public void compileFileMethod () {
    try {
    Process proc = ( Runtime.getRuntime() ).exec ("C:\\MyDocuments\\CYGWIN.BAT); //I also tried to add -c ./scan fileName.txt after .BAT );
    // I also tried to write "C:\\MyDocuments\\BASH.EXE" but it did not help
    OutputStream ostr = proc.getOutputStream();
    BufferedWriter bw = new BufferedWriter ( new OutputStreamWriter (ostr) );
    InputStream istr = proc.getInputStream();
    BufferedReader br = new BufferedReader ( new InputStreamReader (istr) );
    InputStream errorStr = proc.getErrorStream();
    BufferedReader errorBr = new BufferedReader ( new InputStreamReader (errorStr) );
    bw.write("scan case40.10.txt"); /* I am trying to input the scan command to the shell,but it is not working*/
    bw.flush();
    Vector list = new Vector (1) ;
    String str;
    while ( (str = br.readLine() ) != null) {
    list.addElement(str);
    } // End of while
    Enumeration enumForList = list.elements();
    while ( enumForList.hasMoreElements() ) {
    String tempString;
    tempString = ( String ) enumForList.nextElement();
    System.out.println(tempString); // I am trying to read the outputs of the scan command but it is not reading (I can not see any output)
    I tried with and without waitFor( ), it did not work
    // wait for command to terminate
    proc.waitFor();
    // close streams
    br.close();
    bw.close();
    errorBr.close();
    } // End of try
    catch ( IOException ioe ) {
    JOptionPane.showMessageDialog (null, "Input / output error occured while compiling file ", "Error", JOptionPane.ERROR_MESSAGE);
    } // End of catch
    catch ( SecurityException se ) {
    JOptionPane.showMessageDialog (null, "Security error occured while compiling file ", "Error", JOptionPane.ERROR_MESSAGE);
    catch ( InterruptedException ie ) {
    JOptionPane.showMessageDialog (null, "Interruption error occured while compiling file ", "Error", JOptionPane.ERROR_MESSAGE);
    } // End of method compileFileMethod
    // Thank you for your helps and time.

    You cannot invoke BAT files directly, you have to invoke the program that run those files which is your Windows 98 shell. For example (under windows 2000), i would invoke "cmd.exe sricpt.bat some args", rather than "script.bar some args".
    Hope this will help you out.

  • How to associate tips with controls?

    Hi All,
    Is there any way to associate tips with control?
    When my application is running,when the user drags over his mouse on the control,is there any way to s[ecify the purpose of the control.
    ie,if i have a button called "plot",whenever the user drags his mouse over "plot"i want to display a tip indicating that this button's purpose is to plot graph.
    IIs there any way like that?
    Thanks

    Just Rt Click on the Numeric ( or whatever )-->> Description & Tip... thats it.
    Tip will come as tool tip when you run the VI. Description will offer you a detailed help when you do Ctrl+H while running the VI.
    Hope this helps you in more detail.
    - Partha
    LabVIEW - Wires that catch bugs!

  • Any tips on sending output?

    I'm setting up a new duo stage act and the plan is to use Mainstage to run the show. No problems with Mainstage it is working great in rehearsal. We'll be connecting to sound systems supplied by the venues. Some we have experiece with while others will be new.  I like the idea of controlling effects and levels in the software rather than relying on someone who has never heard your music.
    Anybody have some real world tips on plugging into sound systems? Do you recommend sending multiple channels or just a completed mix?
    This is new for us so any tips from actual experience would be greatly appreciated!!!

    Wow, this place is pretty much dead, or no one here uses this software in a stage setting...

  • Bash shell for  sid adm and ora sid user

    I'm planning to make bash shell as the the default shell for my <sid>adm and ora<sid> user. Will there any issues? It seems harmless.
    My current setups are ECC6 on top of  AIX 5.3 and Oracle 10g
    regards,
    Marjan

    The only problem is permission of user access to that bash shell. as well as what u u want to run i mean to say if it is any haevy erport or update insert or refresh functionality then do not run at the time of haevy load.
    Thanks

  • Can not connect to WiFI with IPAD.  Any tips?

    Any tips on how to connect to WiFi.  The IPAD does not find WiFI.  I know that is working as I currently have 3 other devices using currently.

    Some things to try first:
    1. Turn Off your iPad. Then turn Off (disconnect power cord for 30 seconds or longer) the wireless router & then back On. Now boot your iPad. Hopefully it will see the WiFi.
    2. Go to Settings>Wi-Fi and turn Off. Then while at Settings>Wi-Fi, turn back On and chose a Network.
    3. Change the channel on your wireless router (Auto or Channel 6 is best). Instructions at
    http://macintoshhowto.com/advanced/how-to-get-a-good-range-on-your-wireless-netw ork.html
    4. Go into your router security settings and change from WEP to WPA with AES.
    5.  Renew IP Address: (especially if you are drooping internet connection)
        •    Launch Settings app
        •    Tap on Wi-Fi
        •    Tap on the blue arrow of the Wi-Fi network that you connect to from the list
        •    In the window that opens, tap on the Renew Lease button
    6. Potential Quick Fixes When Your iPad Won’t Connect to Your Wifi Network
    http://ipadinsight.com/ipad-tips-tricks/potential-quick-fixes-when-your-ipad-won t-connect-to-your-wifi-network/
    ~~~~~~~~~~~~~~~~~~~~~~~~~
    Fix WiFi Issue for iOS 7
    http://ipadnerds.com/fix-wifi-issue-ios-7/
    iOS 6 Wifi Problems/Fixes
    Wi-Fi Fix for iOS 6
    https://discussions.apple.com/thread/4823738?tstart=240
    How To: Workaround iPad Wi-Fi Issues
    http://www.theipadfan.com/workaround-ipad-wifi-issues/
    Another Fix For iOS 6 WiFi Problems
    http://tabletcrunch.com/2012/10/27/fix-ios-6-wifi-problems-ssid/
    Wifi Doesn't Connect After Waking From Sleep - Sometimes increasing screen brightness prevents the failure to reconnect after waking from sleep. According to Apple, “If brightness is at lowest level, increase it by moving the slider to the right and set auto brightness to off.”
    Fix For iOS 6 WiFi Problems?
    http://tabletcrunch.com/2012/09/27/fix-ios-6-wifi-problems/
    Did iOS 6 Screw Your Wi-Fi? Here’s How to Fix It
    http://gizmodo.com/5944761/does-ios-6-have-a-wi+fi-bug
    How To Fix Wi-Fi Connectivity Issue After Upgrading To iOS 6
    http://www.iphonehacks.com/2012/09/fix-wi-fi-connectivity-issue-after-upgrading- to-ios-6.html
    iOS 6 iPad 3 wi-fi "connection fix" for netgear router
    http://www.youtube.com/watch?v=XsWS4ha-dn0
    Apple's iOS 6 Wi-Fi problems
    http://www.zdnet.com/apples-ios-6-wi-fi-problems-linger-on-7000004799/
    ~~~~~~~~~~~~~~~~~~~~~~~
    iPad: Issues connecting to Wi-Fi networks
    http://support.apple.com/kb/ts3304
    How to Boost Your Wi-Fi Signal
    http://ipad.about.com/od/iPad_Troubleshooting/a/How-To-Boost-Your-Wi-Fi-Signal.hmL
    Troubleshooting a Weak Wi-Fi Signal
    http://ipad.about.com/od/iPad_Troubleshooting/a/Troubleshooting-A-Weak-Wi-Fi-Signal.htm
    How to Fix a Poor Wi-Fi Signal on Your iPad
    http://ipad.about.com/od/iPad_Troubleshooting/a/How-To-Fix-A-Poor-Wi-Fi-Signal-O n-Your-iPad.htm
    iOS Troubleshooting Wi-Fi networks and connections  http://support.apple.com/kb/TS1398
    iPad: Issues connecting to Wi-Fi networks  http://support.apple.com/kb/ts3304
    WiFi Connecting/Troubleshooting http://www.apple.com/support/ipad/wifi/
    How to Fix: My iPad Won't Connect to WiFi
    http://ipad.about.com/od/iPad_Troubleshooting/ss/How-To-Fix-My-Ipad-Wont-Connect -To-Wi-Fi.htm
    iOS: Connecting to the Internet http://support.apple.com/kb/HT1695
    iOS: Recommended settings for Wi-Fi routers and access points  http://support.apple.com/kb/HT4199
    How to Quickly Fix iPad 3 Wi-Fi Reception Problems
    http://osxdaily.com/2012/03/21/fix-new-ipad-3-wi-fi-reception-problems/
    iPad Wi-Fi Problems: Comprehensive List of Fixes
    http://appletoolbox.com/2010/04/ipad-wi-fi-problems-comprehensive-list-of-fixes/
    Connect iPad to Wi-Fi (with troubleshooting info)
    http://thehowto.wikidot.com/wifi-connect-ipad
    10 Ways to Boost Your Wireless Signal
    http://www.pcmag.com/article2/0,2817,2372811,00.asp
    Fix iPad Wifi Connection and Signal Issues  http://www.youtube.com/watch?v=uwWtIG5jUxE
    Fix Slow WiFi Issue https://discussions.apple.com/thread/2398063?start=60&tstart=0
    How To Fix iPhone, iPad, iPod Touch Wi-Fi Connectivity Issue http://tinyurl.com/7nvxbmz
    Unable to Connect After iOS Update - saw this solution on another post.
    https://discussions.apple.com/thread/4010130
    Note - When troubleshooting wifi connection problems, don't hold your iPad by hand. There have been a few reports that holding the iPad by hand, seems to attenuate the wifi signal.
    Some Wi-Fi losses may stem from a problematic interaction between Wi-Fi and cellular data connections. Numerous users have found that turning off Cellular Data in Settings gets their Wi-Fi working again.
    You may have many apps open which can possibly cause the slowdown and possibly the loss of wifi. In iOS 4-6 double tap your Home button & at the bottom of the screen you will see the icons of all open apps. Close those you are not using by pressing on an icon until all icons wiggle - then tap the minus sign. For iOS 7 users, there’s an easy way to see which apps are open in order to close them. By double-tapping the home button on your iPhone or iPad, the new multitasking feature in iOS 7 shows full page previews of all your open apps. Simply scroll horizontally to see all your apps, and close the apps with a simple flick towards the top of the screen.
    Wi-Fi or Bluetooth settings grayed out or dim
    http://support.apple.com/kb/TS1559
    ~~~~~~~~~~~~~~~
    If any of the above solutions work, please post back what solved your problem. It will help others with the same problem.
     Cheers, Tom

  • Installing iCloud, Outlook 2010, setting up contacts sync - any tips?

    Last time I tried this 2 years ago, icloud sucked all my contacts out of Outlook and I had to go through big hoops to back it out.  Any tips on how to do it now?  I'm apprehensive about trying it again.  I have a group of contacts in outlook "iPhone contacts" and I want to only sync them to iCloud, not ALL my contacts. IS there a way to control this?

    Figured it out !
    I finally got calendar and contact syncing to work with Outlook 2010.  See the original post for a description of the problem.  After a long walk to clear my head and consider options, I did the following:
    - Close Outlook
    - From Windows Control Panel - Uninstall the MobileMe and iCloud apps
    - Restart the system
    - Go to Apple web site - Download and re-install iCloud control panel
    - Open iCloud control panel and configure iCloud to sync Mail, Calendar, Contacts
    - Open Outlook, iCloud downloaded Contact and Calendar info
    This worked for me...good luck to others who are having similar problems.

  • Tool Tips on controls?

    hello again,
    just one more question :) i was wondering if anyone knows how to implement tool tips with controls in JavaForte. i looked through the properties window, but didnt see any .ToolTipText property.... i know its possible, and probably just one line of code, anyone know it? thanks a lot in advance for any help! talk to ya later,
    Steven M. Berardi
    [email protected]
    --------------------------------

    I'm not sure if you're refering to components you can place in containers, but if you are, there's a ToolTipText option in the component inspector for every component you can select. If you want to change the tooltips manually for specific components, you can use the method (Component).setToolTipText(String text). Hope that helps...
    hello again,
    just one more question :) i was wondering if anyone
    knows how to implement tool tips with controls in
    JavaForte. i looked through the properties window,
    but didnt see any .ToolTipText property.... i know
    its possible, and probably just one line of code,
    anyone know it? thanks a lot in advance for any help!
    talk to ya later,
    Steven M. Berardi
    [email protected]

  • Problems customizing bash shell

    I am trying to add some customizing environment and aliases to my bash shell but cannot seem to get the .bash_profile file to be recognized when I open a xterm. I can source the file and get it loaded but would rather it be automatic. Any suggestions?
    G4, G5   Mac OS X (10.3.9)  

    I found a post in another area explaining that X11 is invoked as a non-shell start and therefore reads .bashrc and not .bash_profile. Moved my commands to that file and everything works.

  • Any tips to mak your MAC run smoother?

    hi all, just wanted to know any tips on how to make your mac run smoother. Your help is much appreciated

    I agree with Macjack, if it ain't broke... but there you can do maintenance that can help keep a Mac happy:
    http://www.thexlab.com/faqs/performance.html <--- Tuning Mac OS X Performance
    7 top utilities for a Mac: <a class="jive-link-external-small" href="http://">http://mac360.com/index.php/mac360/comments/thetop_7_free_utilities_to_maintain_amac/
    Avoid a cluttered Desktop: http://discussions.apple.com/thread.jspa?messageID=7668937#7668937
    Run Disk Utility and Repair Disk Permissions before and after any software installation. Keep an eye on your free drive space. Control click your MacHD icon on your Desktop. Click: Get Info Under the General category you will see: Capacity and Available. Make certain your free drive space never falls below 15%... (some day 10%).
    Hope this helps... and Happy Holidays!
    Carolyn
    Message was edited by: Carolyn Samit

Maybe you are looking for

  • Connecting to server after upgrading to Snow Leopard

    I'm trying to connect to a hard drive wirelessly which is connected to a router. I used to have Leopard and connected fine by going Finder > Connect to Server  and inputting: smb://FND/Media Since upgrading to Snow Leopard I haven't been able to conn

  • How do I enable "Save As" and disable "Save"

    I have constructed a filable form in Adobe Acrobat Pro 8.1.  The idea is to have this form downloaded to the users computer and used weekly to track expenses and each week to print and save a copy.  The problem is that with save enabled it overwrites

  • Blackberry Messenger

    Hi i have blackberry curve 9360 :womensad: my bbm is not working whenever i send requests to people they dont recieve it and whenever they send me request i dont recieve it.. why is this?? please help  thanks

  • Oracle jdbc drivers - cannot resolve symbol

    while i'm not new to java, i am new to jdbc. need to connect a java app to an oracle database (hosted by a 3rd party). i have all the connection info. i've crafted a test program, but cannot get it to compile. here's the code: import java.sql.*; publ

  • Where to put common classes and jar files

    hi, i want to put some classes and jar files in a common folder so that it can be accessed by other applications is there any way doing that.In tomcat server they have common and shared directories once any classes are into that folder they are being