Here is pretty much the same thing in Java using the BMC Remedy Java API.
I basically just re-implemented Matts script with a few changes
like dropping the ARGetSQL call in favor of a plain getListForm call since
it essentially does the same thing without having to resort to a direct SQL
query. I use MSSQL Server on my dev box so the default clause in there is
worded using MSSQL speak (partitions rather then tablespaces like in
Oracle) but you can adjust the clauses List<String> object as needed to do
whatever you would like. See the comments for where you should be making
changes potentially.
Just remember to have the BMC Java API in your classpath before attempting
to run this for it to work and adjust the connection info for your own
environment (I didn't bother adding an argument parser or making it
interactive like Matt's script for entering connection info as this was
just a quick throw together as I don't use Perl much these days and wanted
to quickly generate an ardb.cfg file, i'll probably clean it up and add
some argument parsing later on when I have time so its all not so
'hardcoded' like below).
Hope this is helpful.
<<<JAVA CODE STARTS BELOW>>>
import com.bmc.arsys.api.ARException;
import com.bmc.arsys.api.ARServerUser;
import com.bmc.arsys.api.Constants;
import com.bmc.arsys.api.Form;
import com.bmc.arsys.api.IndexInfo;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class ARDBGenerator {
private static ARServerUser server;
public ARDBGenerator(String Server, String User, String Password, int
Port) {
server = new ARServerUser();
server.setServer(Server);
server.setUser(User);
server.setPassword(Password);
server.setPort(Port);
}
public static void main(String[] args) {
/* Change variable to suit target AR System Environment */
String Server = "<SERVERNAME>"; // Set this to the proper server
name for your environment
String User = "<USERNAME>"; // Set this to the proper user name
for your environment
String Password = "<PASSWORD>"; // Set this to the proper password
for the user specified above
int Port = <PORT>; // Set this to the proper port or comment out
if using portmapper
ARDBGenerator ars = new ARDBGenerator(Server, User, Password, Port);
ars.connect();
ars.GenerateARDBConfiguration();
server.logout();
}
void connect() {
System.out.println();
try {
server.verifyUser();
} catch (ARException e) {
System.out.println(e.getMessage());
System.exit(1);
}
}
/**
* The following method will auto-generate a Remedy ardb.conf/cfg file
for all schemas with indexes on the system
*/
void GenerateARDBConfiguration() {
try {
File file = new File("ardb.cfg");
if (!file.exists()) {
file.createNewFile();
}
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
List<String> schemaList;
List<String> clauses = new ArrayList<String>();
clauses.add("on INDEXPartition"); // Set this to the proper
partition created for indexes if different from primary
schemaList = server.getListForm(0,
Constants.AR_LIST_SCHEMA_REGULAR);
for (String schema : schemaList) {
Form schemaObject = server.getForm(schema);
bw.write("Form:" + schema + "\n");
for (IndexInfo indexInfo : schemaObject.getIndexInfo()) {
if (indexInfo.getIndexFields() != null) {
bw.write(" Index {\n");
for (Integer indexedField :
indexInfo.getIndexFields()) {
bw.write(" Id:" + indexedField + "\n");
}
for (String clause : clauses) {
bw.write(" Clause:" + clause + "\n");
}
bw.write(" }\n");
}
}
}
bw.close();
} catch (ARException e) {
System.out.println(e.getMessage());
} catch (IOException e) {
System.out.println(e);
}
}
}
On Wed, Sep 5, 2012 at 2:39 PM, Grooms, Frederick W <
[email protected]> wrote:
> It looks like your perl installation does not have the ARSPerl module
> installed.
>
> You can get the ARSPerl module from
> http://sourceforge.net/projects/arsperl/
>
> Fred
>
>
> -----Original Message-----
> From: Action Request System discussion list(ARSList) [mailto:
> [email protected]] On Behalf Of Jamie
> Sent: Wednesday, September 05, 2012 1:13 PM
> To: [email protected]
> Subject: Re: Anyway to populate ardb.conf other than manual?
>
> I got some internal help with trying to run this, but running into errors
> when trying to exectute the procedure:
>
> any thoughts?
>
> [svcremdy@crsnxt003:/homedir/svcremdy]>perl makeardb.pl
> Can't locate ARS.pm in @INC (@INC contains:
> /usr/perl5/5.8.4/lib/sun4-solaris-64int /usr/perl5/5.8.4/lib
> /usr/perl5/site_perl/5.8.4/sun4-solaris-64int /usr/perl5/site_perl/5.8.4
> /usr/perl5/site_perl /usr/perl5/vendor_perl/5.8.4/sun4-solaris-64int
> /usr/perl5/vendor_perl/5.8.4 /usr/perl5/vendor_perl .) at makeardb.plline 10.
> BEGIN failed--compilation aborted at makeardb.pl line 10.
>
>
>
>
> _______________________________________________________________________________
> UNSUBSCRIBE or access ARSlist Archives at www.arslist.org
> attend wwrug12 www.wwrug12.com ARSList: "Where the Answers Are"
>
--
:wq cuga
_______________________________________________________________________________
UNSUBSCRIBE or access ARSlist Archives at www.arslist.org
attend wwrug12 www.wwrug12.com ARSList: "Where the Answers Are"