Runtime.exec() under a specific user account ???

Hi there,
I cann't figure out how to run a script on Unix under a specific user account using the Runtime.exec(). Currently whoever run the java program, the script is ran under that user account.
The code is like:
public class javarun {
public static void main(String[] arg) {
String str = "myunixscript";
// check the arg[1] to decide the appropriate environment.
Runtime r = Runtime.getRuntime();
try {
Process pr = r.exec(str);
pr.waitFor();
int exitstatus = pr.exitValue();
} catch (...) {...}
We have two user accounts: unixusr1 and unixusr2. Now I need to have unixusr1 run the java program ( ie. unixusr1$ java javarun), while the "myunixscript" be executed under unixusr2. One further step is to the unix account name as a parameter so the unixscript could be run under different account.
Any help will be highly appreciated. Thanks.
Edward.

I'm not sure if I have a solution, but here are some questions:
a) have you tried writing additional input to the OutputStream of the process? Although I have not tried it, I would imagine that Process.getOutputStream() exists for commands that require the invoking resource to send additional input to the process- like an su command that requires a password check.
b) can you just write a shell script that takes the needed information as an argument. That is, write a shell script that takes the username and password as an argument and then you can use Runtime like,
Runtime.exec("myScript", new String[] { "hisId", "hisPasswd" });Obviously, you would need to think through the security concerns of such a script, but, if it complies with the security structure of your environment, it might allow you to avoid the problem by using the shell script to invoke the destination command with the proper UID and password, rather then using the JVM to invoke it. Basically, the script becomes a proxy for the JVM to invoke that command.

Similar Messages

  • Always used 1 main account.  Started using individual user accounts. So how do I use software or applications with a lot of data like Quicken under my own user account?

    I recently upgraded our family's mac to OS X.  I thought this was the perfect time to create and use "user accounts".  We had always used 1 main account.  So how do I use software or applications with a lot of data like Quicken under my own user account?  I wanted to be able to manage my own itunes library, iphone apps, messages.  But I still really need to use the Stuff I have in Quicken essentials.  I don't want to have to restart all my work done in Quicken already.

    I haven't used Quicken in a while, but most applications store your files in your Documents folder. Is that where your Quicken data file is? What you do next depends on how many family members need to get at that data.
    If multiple family members need to use the Quicken data file, try moving it to the Documents folder in the Shared account. That is an account that all accounts can see. It's at the same level as the other accounts. In other words, Shared is one level up from your Home account, or Hard Drive/Users/Shared.
    If you're the only one allowed to see that Quicken data, move the Quicken data file from the old main account to your account, and don't leave a copy behind. You can use the Shared folder as a way station for the transfer since you won't be able to see both accounts' Documents folders at the same time (because you're not allowed to peek into other people's accounts). Or you can use another disk or server for the transfer, as long as you can get to it when logged into either account.

  • My question is in regard to pc to mac migration. How do I migrate information from my pc with specific user account to an existing user account on my mac? I do not want to use multiple mac user accounts.

    My question is in regard to pc to mac migration. How do I migrate information from my pc with specific user account to an existing user account on my mac? I do not want to use multiple mac user accounts.

    https://discussions.apple.com/message/16371308#16371308

  • I recently purchased a MacBook Pro, I did not transfer files from my old pc with migration assistant when I set up the MacBook. A few days later I did the transfer, now my Itunes library and everything else from my old pc is under a different user account

    I've already setup the original user account and do not want to do it again, how do I merge the two user accounts into one so all of my stuff is under one user account?

    They are the same Itunes account (mine), but since I transferred the 'user account' with my Itunes library and other files from old pc to my new MacBook, I now have two 'user accounts' on my MacBook. The original I setup when I got the MacBook and the one I transferred from my pc. I've already went thru most of my photos in Iphoto and named all the faces along with general setup of how I want all my settings on my MacBook under the first user account, I don't want to start over and do it all again with the transferred user account, I just want to move my Itunes library I transferred over to my original user account on my MacBook. Does this make any sense? lol

  • Brief report of about 2 months for the sqls run under a specific user ?

    Hi,
    Is there a way i can get the brief report of about 2 months for the sqls run under a specific user in Oracle 11g.
    thanks in advance

    913410 wrote:
    Yes,
    auditing is enabled
    SQL> show parameter audit;
    NAME                                 TYPE        VALUE
    audit_file_dest                      string      /u01/app/oracle/admin/PRCMTDB/
    adump
    audit_sys_operations                 boolean     FALSE
    audit_syslog_level                   string
    audit_trail                          string      DBthen how to get the informationabove is necessary, but not SUFFICIENT
    default Oracle behavior is that NO specific actions are audited.
    You would have had to manually enable AUDIT for all SQL statement by single user

  • Diskutil option to mount under a specific user/UID

    I'm coming from the Linux world and I'm used to the commandline; I'm slowly getting up to speed on OS X' command line tools. This one concerns 'mount'.
    Under Linux, it's possible to mount a disk under a specific UID; for example to mount an internal EXT3-formatted harddrive and assume all files are owned by user with ID 1000, I'd do something like
    $ sudo mount -t ext3 -o uid=1000 /dev/sdb1 /mnt/usbdrive
    For OS X, that doesn't seem possible; we have diskutil and I could certainly mount an extra internal HFS+ drive as follows:
    $ sudo diskutil mount -mountPoint /Volumes/storage /dev/disk1s1
    Is there a way I could force the uid for the mount command?

    I'm not sure if I have a solution, but here are some questions:
    a) have you tried writing additional input to the OutputStream of the process? Although I have not tried it, I would imagine that Process.getOutputStream() exists for commands that require the invoking resource to send additional input to the process- like an su command that requires a password check.
    b) can you just write a shell script that takes the needed information as an argument. That is, write a shell script that takes the username and password as an argument and then you can use Runtime like,
    Runtime.exec("myScript", new String[] { "hisId", "hisPasswd" });Obviously, you would need to think through the security concerns of such a script, but, if it complies with the security structure of your environment, it might allow you to avoid the problem by using the shell script to invoke the destination command with the proper UID and password, rather then using the JVM to invoke it. Basically, the script becomes a proxy for the JVM to invoke that command.

  • No Sound in Flash Player under only one User Account

    Hi I searched the forums and could not find the answer to this.
    I have a Freshly Installed Windows 7 Ultimate (64 bit) version with the latest Flash Player (10.1).
    The browser doesn't matter, both Firefox and IE have the same behavior.
    No sound comes from flash at all under the admin account. Under other user accounts, the sound is fine.
    The sound WAS working fine until one time it said that Flash Player had crashed. I uninstalled, rebooted, re-installed with no luck.
    So I'm either gonna just make another user account... or just wipe the computer and start over unless anyone has any ideas.
    -Marc

    Thanks. Well vs 3.6.8 is the latest FF. There is no Flash Player at all for any 64bit system. You must use the 32bit browser when Uninstalling/Installing and viewing Flash Content.
    For that to happen so suddenly sounds like some update of a program, Windows update, an Anti-Virus update had taken place. Any new program Installed or Uninstalled? Anything you can think of prior to that happening? It just sounds like a major conflict.
    You may want to take a look at your Flash files, perhaps some Flash file didn't get Installed properly.
    Go to C:\Windows\SysWOW64\Macromed\Flash  Open Flash and post back the files listed there. The NPSWF file(s) need a right click and then click on Properties to obtain the version number(s)
    Also go to Tools, manage add ons with IE and find Shockwave Flash Object..ActiveX Control..Flash10h.ocx and make sure it is Enabled.
    Using FF find the SWF vs 10.1.53.64 plug-in and make sure it is Enabled.
    Perhaps when FP crashed it caused something to change in both of the add ons.
    I had that happen to me a few months ago; Uninstalled an Anti-Virus/Installed a new version. Then couldn't see images on a website, and went to an Adobe website to check something and it told me I needed Flash Player to view it!!! Imagine my surprise:-) So that was the problem.
    Thanks,
    eidnolb

  • Mac app store will not connect under a managed user account but will under admin. Please help clear this up?

    After I have installed OSX Mountain lion I clicked on the app store to buy an app. Only one problem, it says it "cannot connect", I then tried under the admin account and it worked no problem. I log back into the managed user account and disable any parental controls that might be interferring, I try again and it worked. I need the mac app store to work under the managed user with parental controls on. I cleared the iTunes store cache and reset the warnings just to see if that might do the trick but no luck. When the latest update was availble I updated immediatly in hopes of that might fixing the problem but again it did not work.  I would really appreciate if anyone had any ideas on how to help solve this issue.
    -Thanks

    Back up all data before proceeding.
    Step 1
    Triple-click anywhere in the line below on this page to select it:
    /Library/Preferences/SystemConfiguration/NetworkInterfaces.plist
    Right-click or control-click the line and select
              Services ▹ Reveal in Finder (or just Reveal)
    from the contextual menu.* A folder should open with an item selected. Move the selected item to the Trash. You may be prompted for your administrator login password. Restart the computer and test.
    *If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combination  command-C. In the Finder, select
              Go ▹ Go to Folder...
    from the menu bar and paste into the box that opens by pressing command-V. You won't see what you pasted because a line break is included. Press return.
    Log out, log back in, and test. If there's no improvement, continue.
    Step 2
    Reset your computer’s PRAM.

  • Problem updating iTunes to 8.2 under all OS user accounts

    I'm posting this for my brother.
    Background: He has an iMac setup with multiple user accounts similar to how I have mine: Administrator, Parents and a separate account for each child. He recently updated iTunes to version 8.2 while logged into his (Parent) account using Admin privileges. I perform my app/OS updates this way as well and any app update is reflected in the respective app under each account. They share a common iTunes Music Store account but keep separate libraries and music folders.
    Problem: After his son updated his iPod touch to 3.0, iTunes blocked the first sync indicating he needed to update iTunes to the latest version. When he checked to see what version his iTunes was under his account, it showed version 8.0. He performed a software update, iTunes 8.2 showed up so he downloaded it and, after admin credentials were entered, he installed the update. No luck. Still 8.0. He did that a couple times with no success. Since then, I've had him restart, trash pref files, and download the full update from the Apple website but nothing has worked. His iTunes still shows as version 8.0 even though all other user accounts on their iMac shows version 8.2 and he can't sync his iPod.
    I don't believe OS X installs multiple instances of an app for user account purposes so I'm truly baffled by this. Should I uninstall iTunes in his user account? Under the Parent account? Which account "owns" the iTunes app? Is there some other way to get it to update?
    I've searched the forums and Googled the issue and I can't find a similar issue anywhere. Any help would be appreciated.

    We did that as well. They can only find one version of iTunes in the Applications Folder. "Get Info" on the main account shows version 8.2 yet a "Get Info" on the kids account shows version 8.0. Performing an upgrade check from within the kids accounts finds the 8.2 updater and after running it, it indicates that the upgrade was successful. Once the upgrade is applied, the version still remains at 8.0.
    Has no one else encountered this? I'm afraid to uninstall iTunes in the kids accounts because I don't know what it will do to the main iTunes.

  • Microsoft Word cannot open on specific user account.

    Hello,
    Everytime I open Microsoft Word (Office 2011) on my original user account, I get this message:
    I went to Microsoft's support site first. After finding various methods here, I found that the second method actually worked for me. That method was to make a "test" user account, and try to open Word there. Word had an update available and I updated both accounts with it. The "test" account actually opens up Word with no problems, whereas my original user account does not. Apple Support didn't help, in fact they directed me back to Microsoft because it's a third party software developer, despite it being an Apple/Macbook user account problem. I was wondering if anyone knew how to fix this, or if I'm stuck transferring all my files over to my test account one by one?
    Thanks.

    Maxie1111,
    Just a shot here,if you have done all the steps you have provided in the link,  in your affected acct, try going to Applications, Microsoft Office, Word and highlight it. Then press COMMAND I or right (control) click on it, this will bring uo the info pane, at the bottom under "sharing and permisssions make sure that system, and the rest of the accts have read write access, if not try unlocking the padlock (at the bottom with your admin pswd) and changing the status, see if this helps.
    ATB

  • Launch Acrobat Reader with Runtime.exec() under WINNT4, without absolut pat

    Hi,
    I would like to launch Acrobat Reader from a Swing application. This works fine with Runtime.exec() as long as I provide the full path to the AcroRd32.exe. The problem is that I cannot predict the location of this exe on the systems of the users. Athough is in the Windows PATH, since I can launch from the windows execute-dialog, the Runtime.exec() is not able to locate the file.
    How can I solve this problem?
    Thanks a lot!
    Horst

    hey BIJ, thank you so much man. start really does wonders!! i was stuck with invoking a fortran program for last couple of days and now i went through your postings and tried with start. it did work!!
    thanks again,
    bhairampally

  • Problem Logging Into A Specific User Account - OS X Leopard

    Hello,
    I need assistance with a problem of logging into a specific account in Leopard. It would get stuck in space vortex screen. I have no problem logging in with another account. I tried deleting the account/folders and creating the account with the same user but it would get stuck in the same screen. I don't have a problem logging in with another newly created user id.
    I tried locate information relating to this specific problem but was unsuccessful. Any assistance will be great appreciated.
    Regards

    Hello,
    Somehow I fixed the issue by deleting the user account and fixed the disk permission.

  • Turn on Mac in specific user account

    Can you schedule mac to turn on to schedule in energy saver and login as specific user, so that it can then run a scheduled chronosync and then shut down, but not autologin as that user when normally turned on. Want to backup at night from my user account, but don't want it to auto login when kids turn it on

    Hi,
    No way I'm aware of.

  • Runtime.exec() with language specific chars (umlauts)

    Hello,
    my problem is as follows:
    I need to run the glimpse search engine from a java application on solaris using JRE 1.3.1 with a search pattern containing special characters.
    Glimpse has indexed UTF8 coded XML files that can contain text with language specific characters in different languages (i.e. german umlauts, spanish, chinese). The following code works fine on windows and with JRE 1.2.2 on solaris too:
    String sSearchedFreeText = "Tür";
    String sEncoding = "UTF8";
    // Convert UTF8 search free text
    ByteArrayOutputStream osByteArray = new ByteArrayOutputStream();
    Writer w = new OutputStreamWriter(osByteArray, sEncoding);
    w.write(sSearchedFreeText);
    w.close();
    // Generate process
    String commandString = "glimpse -y -l -i -H /data/glimpseindex -W -L 20 {" + osByteArray.toString() + "}";
    Process p = Runtime.getRuntime().exec(commandString);
    One of the XML files contains:
    <group topic="service-num">
    <entry name="id">7059</entry>
    <entry name="name">T&#195;&#188;rverkleidung</entry>
    </group>
    Running the java code with JRE 1.2.2 on solaris i get following correct commandline
    glimpse -y -l -i -H /data/glimpseindex -W -L 20 {T&#195;&#188;rverkleidung}
    --> glimpse finds correct filenames
    Running it with JRE 1.3.1 i get following incorrect commandline
    glimpse -y -l -i -H /data/glimpseindex -W -L 20 {T??rverkleidung}
    --> glimpse finds nothing
    JRE 1.2.2 uses as default charset ISO-8859-1 but JRE 1.3.1 uses ASCII on solaris.
    Is it possible to change the default charset for the JVM in solaris environment?
    Or is there a way to force encoding used by Runtime.exec() with java code?
    Thanks in advance for any hints.
    Karsten

    osByteArray.toString()Yes, there's a way to force the encoding. You provide it as a parameter to the toString() method.

  • How do you use Time Machine to restore a specific users account?  I can't do it from the user screen because I am not allowed.  I can't do it from the admin because I can't see other users in Time machine.

    I can't restore my user account from the users screen because I get an alert that Mac OS needs something.  I can't restore in TimaeMachine from the Admin screen because I can't see other users home folders.  What can I do?

    See Pondini's TM FAQs for starters.

Maybe you are looking for