Glassfish: How to do asadmin commands without password?

glassfish, linux

Solution

You can set the password from a file instead of entering the password at the command line.

The --passwordfile option takes the file containing the passwords:

AS_ADMIN_PASSWORD=value
AS_ADMIN_ADMINPASSWORD=value
AS_ADMIN_USERPASSWORD=value
AS_ADMIN_MASTERPASSWORD=value

Problem

every time I enter a CLI-command for glassfish like this `asadmin start-instance i1` I am prompted to enter the admin-username and admin-password. How can I disable the need for entering these credentials? I plan to write scripts for running commands like this and I think it's not possible to enter the credentials in a bash script. Thanks

Original source