Passing password in an AS script to a shell command

Hi,
I'm posting here based on this discution:
http://discussions.apple.com/thread.jspa?threadID=345269
In my case I want to pass the password to the rsync command. The command I use is on the format:
rsync -vr --size-only ~/Sites/ usernameonserver@serveuraddress:/path/to/the/directory
Normally rsync will ask for a password. How the password and username are passed from AS to terminal (or what is equivalent to)?
it is important to mention that the user and password are not local, but on the remote server.
Thanks

Hi Steve,
As you've probably gathered, from this post and the other thread you linked to, AppleScript doesn't really offer a straightforward way to run command line tools that require user interaction.
The suggestions NovaScotian offered may work for your rsync dilemma, but I thought I'd mention another option that you might want to investigate for this or other similar problems. There is a command line tool called "expect" that is specifically tailored for automating the running and interaction with other commands that require user responses. See the man page for "expect" for specifics.
Basically "expect" allows you to write a script that controls what other process it launches, what prompts to wait for and what values to feed to the prompts. These expect scripts can be as complex as you need to make them and they can deal with multiple secondary processes if needed. The expect script can sort of act as a "middle-man" between AppleScript and the actual command line tool(s) you want to run. AppleScript runs an expect script, the expect script runs the command you really want to execute and deals with any interactive prompts and finally returns any results back to the AppleScript.
So, getting back to your rsync problem... you could write your AppleScript to call an "expect" script passing it the rsync password. And you would write your expect script to accept the password as one of it's command line parameters. The expect script would then launch rsync, wait for the password prompt and then feed rsync the password you gave it from AppleScript. The expect script would finally return any output or error messages from rsync back to AppleScript.
This may be overkill for your particular problem since rsync apparently gives you other mechanisms for dealing with the password. But in some situations it may be the best or only solution for running interactive command line tools from AppleScript.
Steve

Similar Messages

  • Passing Multiple Parameters to SQL Script from a Shell Script

    Hi Friends,
    I have SQL script which accepts 6 parameters.
    I am calling this from a shell script as shown below:
    sqlplus -s  ${ORACLE_ID} @${SQLPATH}KORONT_041.sql ${USER_ID} ${PDC} ${item_number} ${KORDC} ${PDCSET} ${last_Updated_in_hours} Out of the six parameters, item_number is not a mandatory parameter.
    When i pass all six parameters, there is no issue.
    But when i leave item_number blank, i am getting the below error
    Enter value for 6:
    User requested Interrupt or EOF detected.Based on the error, it seems that the NULL values for item_number is ignored and SQL*PLUS is waiting for one more input from user.
    How can i overcome this issue?
    Regards,
    Sreekanth

    Hi,
    I am calling the shell script from concurrent program and below is the log file of the concurrent program.
    Copyright (c) 1979, 1999, Oracle Corporation. All rights reserved.
    KORONT_041_SH module: KORONT - Daily Item Master Update
    +---------------------------------------------------------------------------+
    Current system time is 29-JUN-2011 10:09:35
    +---------------------------------------------------------------------------+
    REQUEST_ID: 68510795
    USER_ID: 4219
    PDC:    85
    Item Number:
    KORDC:    124
    PDCSET:   1100000003
    last_updated_in_hours: 24
    EMAIL_ID: [email protected],[email protected]
    SQLPATH: /e381/oracle/asodev01appl/custom/motont/1.0.0/sql/
    RPTDIR:  /e381/oracle/asodev01comn/admin/out/ASODEV01_asoprdb2
    RPTFILE: o68510795.out
    Table truncated.
    *Enter value for 6: User requested Interrupt or EOF detected.*
    Table truncated.
    old  15:       AND ic.organization_id   = &&4
    new  15:       AND ic.organization_id   = 1100000003
    0 rows created.
    Input truncated to 9 characters
    old   8:                AND organization_id   = &&4
    new   8:                AND organization_id   = 1100000003
    0 rows created.
    End of SQL
    No record.
    +---------------------------------------------------------------------------+
    Executing request completion options...
    +------------- 1) PRINT   -------------+
    Printing output file.
                   Request ID : 68510795      
             Number of copies : 0      
                      Printer : noprint
    +--------------------------------------+
    Finished executing request completion options.
    +---------------------------------------------------------------------------+
    Concurrent request completed successfully
    Current system time is 29-JUN-2011 10:09:38
    +---------------------------------------------------------------------------+Regards,
    Sreekanth

  • Passing password from shell script to Java

    Hi there,
    I have a shell script which has user id and password stored in variables. I call a java program from this shell script. I tried accessing this environment variable from java using system.getproperty and java is not getting the values. I have used export USERID PASSWORD
    and java classname to call it.
    I do not want to pass it as arguments because of security reasons. can anybody help me please.
    Thanks a bunch.

    Hi there,
    I have a shell script which has user id and
    password stored in variables. I call a javaprogram
    from this shell script. I tried accessing this
    environment variable from java using
    system.getproperty and java is not getting the
    values. I have used export USERID PASSWORD
    nd java classname to call it.
    Presumably you are using one of the newer java
    versions.
    Questions
    1. What statements are you using to set, export and
    run java?
    2. What shell are you using?
    3. How are you accessing the vars in java?
    I do not want to pass it as arguments because of
    security reasons. can anybody help me please.
    That is nonsensical. Putting it in env vars exposes
    it more than passing it as args.Thanks for replying jschell.
    1. I am using newer version java 1.5
    2. shell scripts gets it's variables from oracle reports through webservices.
    3. to run java i use java javaclassname3. I used EXPORT variablename and in java called system.getproperty(variablename)But system.getproperty is getting a null.
    And the decision about not passing it as args was made by our client. They think it's not safe to pass password.
    are they wrong??
    Please help me.

  • How to Pass password to Run as a Network Account in powershell

    Hello,
    I ve been asked to raise this as a new topic as given in the link. The response also says that it is not possible to pass the password of a network account in powershell. How else can I implement the requirement?
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/41a4ba3d-93fd-485b-be22-c877afff1bd8/how-to-run-a-powershell-script-in-admin-account?forum=ITCG&prof=required
    My requirement is that, I am need to run the powershell script via a network account. The powershell is called via a script on an ETL tool. When I ask it to print the output of the below command, the output says " Enter
    the password of domain\username:". 
    PS > runas
    /user:{domain}\{username} powershell -file {nameOfPowershellScript.ps1}
    Hence I had to modify the code to pass the password also in the same command. I am new to powershell scripting and the below command doesn't work.
    Please suggest the appropriate way to pass the password of the network account.
     Referred to a link http://technet.microsoft.com/en-us/magazine/ff714574.aspx. 
    $password = Get-Content c:\temp\password.txt | ConvertTo-SecureString 
    $credential = New-Object System.Management.Automation.PSCredential
    "CachedUser",$password 
    PS > runas
    /user:{domain}\{username} powershell -file {nameOfPowershellScript.ps1}
    PS >$credential.Password | ConvertFrom-SecureString | Set-Content
    c:\temp\password.txt 

    Thanks for the pointer. Question that I have is I am referencing sqljdbc4.jar in my application, which in turn using sqljdbc_auth.dll.
    Which one should i refernce through <nativelib>. Is it sqljdbc4.jar or sqljdbc_auth.dll.
    have added the following line to the .jnlp.
    <nativelib href="sqljdbc4.jar"/>
    But still it is complaining on sqljdbc_audth.dll. If it is sqljdbc_auth.dll, can I use <nativelib> to pass it.
    In that case does it need to be signed?. If so,
    Is it possible to sign .dll using 'jarsigner'?.
    Edited by: 878645 on Apr 26, 2012 3:43 PM

  • Need javascript/VB code to open password protected PDF file by passing password in code itself.

    Hi,
    I have used PDFcreator to create the PDF file with password security
    'To create PDF file with password security
    With PDFCreator1
    .cOption("UseAutosave") = 1
    .cOption("UseAutosaveDirectory") = 1
    ' ==============
    .cOption("AutosaveDirectory") = strBackupPath '& "\" & Format(Trim(Sheets("Form16_Database").Range("A" &
    I).Value), "0#####") & "\" 'ActiveWorkbook.Path
    Debug.Print Trim(Sheets("Form16_Database").Range("A" & I).Value) & "Form16-" & Format(Trim(Sheets
    ("Form16_Database").Range("A" & I).Value), "0#####") & "-" & Format(Now(), "YYYYMMDDHHMMSS") & ".PDF"
    .cOption("AutosaveFilename") = Format(Trim(Sheets("Form16_Database").Range("B" & I).Value), "0#####") & ".PDF"
    FileName = Format(Trim(Sheets("Form16_Database").Range("B" & I).Value), "0#####") & ".PDF"
    .cOption("AutosaveFormat") = 0
    .cOptions.PDFUseSecurity = 1
    .cOption("PDFOwnerPass") = 1
    .cOption("PDFOwnerPasswordString") = "mypass"
    .cOption("PDFUserPass") = 1
    .cOption("PDFUserPasswordString") = "mypass"
    .cClearCache
    End With
    'Printing to PDF Creator
    ActiveSheet.PrintOut Copies:=1, ActivePrinter:="PDFCreator"
    'Making the system wait for the PDF creator to create the file
    Do Until PDFCreator1.cCountOfPrintjobs = 1
    DoEvents
    Sleep 1000
    Loop
    PDFCreator1.cPrinterStop = False
    Sleep 1000
    ''and To fix digital signature used below code from Acrobat SDK 8.1..
    ''VB code for fixing Digital Signature --calling jaascript file from SDK.
    Sub GetDigitalSignature(PDFFilepath As String, PDFFileName As String, PFXfile As String, Password As String, Top As Double,
    Left As Integer)
    Dim gapp As Acrobat.AcroApp
    Dim gpddoc As Acrobat.AcroPDDoc
    Dim jso As Object
    Dim FullPath As String
    Dim avDoc As CAcroAVDoc
    Dim boK As Boolean
    Dim ppklite As Object
    Set avDoc = CreateObject("AcroExch.AVDoc")
    Set gapp = CreateObject("acroexch.app")
    Set gpddoc = CreateObject("acroexch.pddoc")
    boK = avDoc.Open(PDFFilepath, PDFFileName)
    gpddoc.Open (PDFFilepath)
    Set jso = gpddoc.GetJSObject()
    jso.SetUserPassword (Password)
    jso.SetUserDigitalIDPath (PFXfile)
    jso.SetSignTop (Top)
    jso.SetSignLeft (Left)
    jso.app.execMenuItem ("ADBESDK:AddSignature")
    avDoc.Close (True)
    gapp.Exit
    End Sub
    Now i am able to create PDF with Digital signature. But We want to assign password protection too..and problem is once we fix Digital signature we can't change security.
    My problem is to pass password at the time of opening PDF for embedding signature. Password window should not prompt to the user while running VBA application.
    Can you please help me to pass password on fly when file prompt password while opening PDF file. As file need to be opened at the time of fixing signature using sdk javascript code.

    Correct, you need to encrypt then sign.
    Unfortunately, there is no way to pass a password for opening.

  • Can we pass paramters in the partition script

    Can we pass parameters in the partition script in Essbase. Where the parameters are read by a windows batch file which is executed in windows environment.
    Our Business requirement, the business will key in the parameters ie(Month and Year) in a partition script dynamically.
    We are scheduling the partition script through Windows Batch file.
    So is it possible to create a parameter file in windows and pass these parameters to windows batch file.It should be dynamically mapped with partition Script.If possible,can anyone provide sample script to show how it works.

    Thank You Wills. The requirement is the users want to change the mappings in the partition script, but users are not having any access to the EAS. They want the mappings to be dynamically changed in the partition script on adhoc basis.
    Admin can change the values to the substituion variables, but the requirement is users wants to change the mappings.
    So they asked for the parameter file.

  • How to pass a parameter into RMAN script

    Hello,
    I have the following rman script :
    run {
    CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
    CONFIGURE CONTROLFILE AUTOBACKUP OFF;
    CONFIGURE DEVICE TYPE DISK PARALLELISM 2;
    CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT 'c:\oracle\RmanORCL102\ora_df%t_s%s_s%p';
    This script called configure.rman is launch by a .bat script with the following command:
    rman target 'sys/sys12@ORCL102 as sysdba' @c:\oracle\RmanORCL102\configure.rman
    How can I pass a parameter into rman script, I want to pass an additional directory like this:
    rman target 'sys/sys12@ORCL102 as sysdba' @c:\oracle\RmanORCL102\configure.rman v_dir_name
    And use it in rman script:
    CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT 'c:\oracle\RmanORCL102\$v_dir_name\ora_df%t_s%s_s%p';
    Is it a way to do this?
    Regards,
    Elodie

    One option would be to create a file called backup.bat with the following:
    echo run {
    echo CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
    echo CONFIGURE CONTROLFILE AUTOBACKUP OFF;
    echo CONFIGURE DEVICE TYPE DISK PARALLELISM 2;
    echo CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT 'c:\oracle\RmanORCL102\%1\ora_df%t_s%s_s%p';
    echo } ) | rman target sys/sys12@orcl102and then call the script as:
    c:\> backup.bat backup_directory_name

  • Passing concurrent parameter to OS script

    I have a printer driver that calls an OS script and I want to pass a parameter value to that script from a concurrent program that uses that driver via a specific style.
    Is there anyway to reference the concurrent parameter? I'm already passing the filename to the script via $PROFILES$.FILENAME. Is there a similar reference to a parameter value that I could use?
    Any help would be much appreciated.
    Thanks,
    Todd

    Hi Todd
    I thinh this will only get the concurrent request id what he wants is to send the send the parameter to it.. Will it work.. I am not sure.. Just put my views thats all..
    Sunil

  • Pass credentials to cmd in script block

    Hi all so I'm invoking .cmd files to install software with cmd on remote machines using the invoke command in Powershell. It works fine for must software however when I try to install powershell on a remote machine it throws an exit code 5. I looked this
    up and it is a credential error. Is there anyway for me to pass my credential in the script block but also to cmd?
    Here is what I have now:
    Invoke-Command -ComputerName $item -Credential $cred -ScriptBlock {cmd /c "C:\Package\install.cmd"} -AsJob
    Thanks!

    What does your install.cmd actually do? Does it pull from another server or do anything related to a different remote system? If so, that will be denied by design as it is a 'double hop'. You would either need to enable CredSSP on that server or setup a
    RunAsAccount on the remote endpoint to allow access to another remote system from your current system that has the endpoint.
    cmd doesn't take credential objects and this shouldn't be an issue as you are passing your credentials to the scriptblock by default with the remote endpoint via the -Credential parameter. If you wanted to run cmd from another process under your provided
    credentials, you would need to use Start-Process with the -Credential parameter, but again, this is only going to be useful if you wanted to supply alternate credentials beyond what you are providing with Invoke-Command.
    Boe Prox
    Blog |
    Twitter
    PoshWSUS |
    PoshPAIG | PoshChat |
    PoshEventUI
    PowerShell Deep Dives Book

  • How to pass password from jsp to Applet

    Hi ,
    I can pass the user to applet like below. But password will be seen from view source.
    How can pass password without showing in the view source.
    <PARAM NAME="loginname" VALUE="<%=request.getParameter("loginname")%>">
    <PARAM NAME="loginpassword" VALUE="<%=request.getParameter("loginpassword")%>">
    Thanks in advance.
    Rockesh

    Or alternatively, determine why you need to pass the password on to the Applet.
    For example, if the Applet needs to log into a resource, it is much more secure to ask the user for a password then, as opposed to getting the password from a form, passing it on to the Applet and then having the Applet blindly relay the password to the server, the database, whatever.
    If the Applet doesn't need to do anything with the password, then I must question the wisdom of passing on the password in the first place.
    If the Applet uses the password to do authentication, then the best solution is to generate hashes of the password and compare those hashes as needed. This would make it much more difficult for someone to either eavesdrop on it, or guess it through random trial and error. We can take it one step further. When the JSP code is executed - generate a one time unique password that's extremely long, at least 128 characters. Embed the password in the resulting HTML page as a hidden field and seed the Applet with the password. That would tie the Applet to a particular web page.
    I really like SpinyNorman's JavaScript, but if that's indeed your purpose, you might as well do it in the Applet itself. In other words, it's kind of pointless to ask for a password in order to launch the Applet - once the user gets the Applet's URL by some means, he can just bypass the JavaScript authentication.

  • Scripting - Passing and Enterprise variable from script to script

    Hello all,
    We are using UCCX 7.0_SR5
    I am looking to be able to pass a captured variable from one script to another.
    We use a message in queue where a caller waiting in queue can choose to leave a message and then that message is queued back into the sytem for the next available agent. When that agent recieves the message in queue they basically call back out to the customer leaving the message.
    We capture a variable in the first script when they decide to leave a message. The variable holds the call back number that they enter into the system. There is a second script that presents these message in queue calls to the agents. We would like to pass that variable that holds the number enterend by the customer to the second script so that that number appears on CAD in the enterprise data fields. The reason behind this is so the agent has a number to call back in the event they don't reach anyone when the system calls back out and the message left by the customer does not contain a call back number.
    How can I pass that variable from one script to another so it can be presented in CAD for the agents?
    Thanks for any help and let me know if you need any further information.

    You would use a "Get Call Contact Info" step to set your callerID variable, where the "Calling Number" attribute is set to your callerID variable.

  • Passing user parameters to groovy script

    From OIM 11gr2 ,I need to create users into LDAP through OID connector OID-11.1.1.6.0.
    After creation , i need to pass user id and other parameters to groovy script to run a command on target system.
    How do i pass these parameters to groovy script. Please assist

    Hi,
    I am calling the shell script from concurrent program and below is the log file of the concurrent program.
    Copyright (c) 1979, 1999, Oracle Corporation. All rights reserved.
    KORONT_041_SH module: KORONT - Daily Item Master Update
    +---------------------------------------------------------------------------+
    Current system time is 29-JUN-2011 10:09:35
    +---------------------------------------------------------------------------+
    REQUEST_ID: 68510795
    USER_ID: 4219
    PDC:    85
    Item Number:
    KORDC:    124
    PDCSET:   1100000003
    last_updated_in_hours: 24
    EMAIL_ID: [email protected],[email protected]
    SQLPATH: /e381/oracle/asodev01appl/custom/motont/1.0.0/sql/
    RPTDIR:  /e381/oracle/asodev01comn/admin/out/ASODEV01_asoprdb2
    RPTFILE: o68510795.out
    Table truncated.
    *Enter value for 6: User requested Interrupt or EOF detected.*
    Table truncated.
    old  15:       AND ic.organization_id   = &&4
    new  15:       AND ic.organization_id   = 1100000003
    0 rows created.
    Input truncated to 9 characters
    old   8:                AND organization_id   = &&4
    new   8:                AND organization_id   = 1100000003
    0 rows created.
    End of SQL
    No record.
    +---------------------------------------------------------------------------+
    Executing request completion options...
    +------------- 1) PRINT   -------------+
    Printing output file.
                   Request ID : 68510795      
             Number of copies : 0      
                      Printer : noprint
    +--------------------------------------+
    Finished executing request completion options.
    +---------------------------------------------------------------------------+
    Concurrent request completed successfully
    Current system time is 29-JUN-2011 10:09:38
    +---------------------------------------------------------------------------+Regards,
    Sreekanth

  • Changing Simple Pass password

    How do I change my Simple Pass password?

    Hi,
    You may want to check Password Manager on the following document:
       HP Simplepass
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • Pass password to ssh

    Hi,
    it's possible to pass password into ssh-add? If it is, how? I want to unlock key automatically after reboot.

    Thanks of answers ^_^
    graysky wrote:Which greeter are you using (lxdm, lightdm, gdm, etc)?  Check the wiki for this topic.
    I am using autologin via systemd with XServer autostart
    https://wiki.archlinux.org/index.php/Au … al_console
    https://wiki.archlinux.org/index.php/Start_X_at_Login
    jasonwryan wrote:That sort of undermines the whole point of having a passphrase in the first place.
    No, it doesn't. I don't wan't to input password every time I restarted my laptop, but I don't want to keep my key unprotected for cases
    when someone copies it.
    jasonwryan wrote:This sounds like an XY Problem. What are you trying to achieve?
    Possibly it is. I am trying to achieve:
    After autologin my ssh key is in keychain (https://wiki.archlinux.org/index.php/SSH_Keys#Keychain), gnome-keyring and others seems
    just to heavy and I can use it without writing my password. Writing my password for the key once is accetable, however need to manually
    write ssh-add is not.
    So if key will be added automatically on "ssh host" and I must input password first time I connect somewhere, I am fine with it..
    I hope I made clear what I need.

  • How to create script that run sudo-command, via automator?

    Hi
    I'd want to create script to automate one command I need quite often. I just can't get this to work.
    I'm not using english OS, but I think this is what I do. In automator I choose Utilities -> Run script
    Here's the script I try to run:
    sudo "/Library/Application Support/VMware Fusion/boot.sh --restart"
    I found some tip to do it like this:
    do shell script "sudo /Library/Application Support/VMware Fusion/boot.sh --restart password "pass" with administrator privileges
    Where pass is my admin password.
    This does not work, either.
    Could anybody help me on this?
    Thanks...
    Tomi Toivonen
    Message was edited by: Tomi

    This is not working. What's wrong?
    What's wrong is that the '--restart' is a parameter for boot.sh, and therefore needs to be included within the quotes.
    Additionally, the shell uses spaces to divide parameters, so the spaces in the command will make it appear as multiple commands - '/Library/Application', 'Support/VMware' and 'Fusion/boot.sh'. You need to escape them using a backslash:
    <pre class=command>do shell script "/Library/Application\ Support/VMware\ Fusion/boot.sh --restart" password "pass" with administrator privileges</pre>
    If it's outside of the quotes it would be interpreted as a parameter to 'do shell script' and it won't know what to do with that.

Maybe you are looking for

  • Regarding hr reports.

    hi, i am new to hr module. but i got this types of reports from my hr consultant. Human Resources Department Functional Area: Company Clinic Report title Short description1. Employee Data Includes ID#, Medical History, Age, Dependents, Gender 2. Medi

  • Mac Mini (late 2009) won't connect to wireless internet

    The strangest thing happened to me just recently, a conflicting IP address appeared on my Mac Mini (late 2009) a few days ago. This IP was from one of my other computers. After this other computer had been shut down ever since, I keep on getting thes

  • My Blackberry Curve 9380's screen won't turn on!

    My Blackberry Curve 9380's display screen won't turn on!  The flashing red light still appears so I guess I am still able to receive texts.  I can also receive calls; my ring tone goes off but I cannot answer!  I have to unlock it and I can't do anyt

  • Legal to use Weblogic libraries in CI environment?

    Hello, In my company we are using fully licensed copies of Weblogic server (9.2 and 10.1) in test and production environments, as well as free download versions in developer workstations under Free Developer License. The applications we develop make

  • MVC - adding dynamic controls to each row in list

    I'm using VS.Net 2013/C#/Razor I have a dynamically created table with employee data (name/emp number/start date/title). We're trying to keep track of the percent of an employee's job doing certain duties. What I need (for each employee) is to add a