search tips






























Legal Disclaimer (Our attorneys made us say this!)
Stirling Systems Group, LLC makes no warranties or representations, express or implied, without limitation, and in no event will Stirling Systems Group, LLC be liable to you or any party for ANY loss including time, money, goodwill and consequential damages which may arise from your use of these scripts. By requesting these scripts, you agree to the above terms.

Technical Disclaimer (Our consultants made us say this!)
Keep in mind, tailoring these scripts to your environment requires a strong working knowledge of Perl and shell scripting. If you would like a Stirling consultant to help you, contact us for a price quote.

Now that we've said all that, these scripts are free! The functionality of each script is listed below.

If you would like to receive a script, email toolkit@stirlingsystems.com.

BulkCopy.prl

Description

Copies specified files, single or multiple, from one directory to another, even if a failure occurs in a single file copy. At the end of the file transfer, a report will print any errors.

Command Syntax

BulkCopy.prl <directory_path> <file_name> <destination_path>

Parameters (Required)

<directory path>
The directory path the file(s) is(are) in.
<file name(s)>
The file(s) that you want copied.
<destination path>
The destination path of the file(s) .

Return Codes

0
The specified file(s) copied successfully to the desired path.
1
Invalid number of arguments, check the command syntax.
3
There were no files in the source path. Make sure the files are in the specified path.

Error Messages

  • Error: Invalid number of arguments
    Usage: Bulkcopy.prl directory_path file_name destination_path
    There was an error in the syntax of the command. Make sure the correct number of arguments was passed.
  • There are no $source files in $path
    There were no files in the specified source path. Make sure the files to be copied are in the specified path.

Examples

  • BulkCopy.prl /usr/platinum *.txt /usr/bin
    Copies all files in the directory /usr/platinum with the extension .txt, to the directory /usr/bin. After the files have been copied, a report will show any errors.

CheckFileSize.prl

Description

Checks the file size. If the file size is less than the desired minimum, an error report is generated.

Command Syntax

CheckFileSize.prl <filename> <minimum file size>

Parameters (Required)

<filename>
The name of the file you want to check for size.
<minimum file size>
The minimum size of the specified file.

Return Codes

0
The specified file is at least the minimum desired size.
1
Invalid number of arguments passed. Check the syntax of the command line.
3
File size is less than the desired minimum size.

Error Messages

  • Error: invalid number of arguments passed
    Usage: CheckFileSize.prl filename min_size
    There was an error in the syntax of the command. Make sure the correct number of arguments was passed.
  • Error: <file> is less than <minimum file size>
    The specified file is less than the desired minimum size.

Examples

  • CheckFileSize.prl file.txt 3454
    Verifies that file.txt is at least 3454 bytes. If not, the script generates an error report.

CheckLrecl.prl

Description

Checks each record to see if it is a specified length.

Command Syntax

CheckLrecl.prl <file_name> <lrecl>

Parameters (Required)

<file_name>
The filename that you are checking for record length.
<lrecl>
The length of each record that the file is being checked against.

Return Codes

0
Each record is the desired length.
1
Record lengths do not match.
2
Invalid number of arguments. Check the syntax of the command line.
3
The file does not exist. Check the path for the file.

Error Messages

  • Error: Invalid number of arguments passed.
    Usage: CheckLrecl.prl file_name lrecl
    There was an error in the syntax of the command. Make sure that the correct number of arguments was passed.
  • Warning: Record lengths do NOT match
    The record lengths do not match the length submitted by user.
  • Warning: $file doesn't exist
    The specified file does not exist. Make sure the file is in the specified path.

Examples

  • CheckLrecl.prl file.txt 10
    Checks file.txt for the records and verifies that the record length is equal to 10.

CheckHeader.prl

Description

Checks if there are delimiters in the file header. If there are delimiters, prints name of file and date. This is useful when you desire a check to see if a header changed within a file at a specific time.

Command Syntax

CheckHeader.prl <filename> <string>

Parameters (Required)

<filename>
The file name that you want to check.
<string>
The string that you're looking for in the header.

Return Codes

0
The specified string was found in the header.
1
The specified string was not found in header.
2
Invalid number of arguments. Check the syntax of the command.
3
The specified file could not be found. Check the location of the file and make sure it exists in that location.

Error Messages

  • Error: invalid number of arguments passed
    Usage: CheckHdr.prl filename string
    There was an error in the syntax of the command. Check to be sure the correct number of arguments was passed.
  • Warning: <filename> does not exist
    The specified filename does not exist. Check the location of the file to be sure that it exists in the specified location.
  • The string <header string> was NOT Found
    The specified string was not found in the header.

Examples

  • Checkheader.prl file.txt 2/7/94
    Checks file.txt for the string 2/7/94. If the string does not exist, an error report is generated.

CheckTime.prl

Description

Reruns an interface based upon the conditions being met and/or during the time window. This will allow the interface to not run at a time when the conditions have been met, but the conditions were met outside the specified time window.

Command Syntax

CheckTime.prl <time>

Parameters (Required)

<time>
The desired time.

Return Codes

0
The time is the desired time.
1
The time is not the desired time.
2
Invalid number of arguments passed. Check the syntax of command for errors.

Error Messages

  • It is not time
    The current time is not the desired time.
  • Error: Invalid number of arguments passed.
    Usage: Checktime.prl target_time
    An invalid number of arguments has been passed. Check the syntax of the command line.

Examples

  • Checktime.prl 12:30
    Checks to see if current time is equal to 12:30.
ContProgRun.prl

Description

Reruns an interface until the interface exists with a certain exit code. This means that a situation has arisen that would compromise the environment if the interface reran at that time.

Command Syntax

ContProgRun.prl <time> <sleep_seconds> <program_name and parameters> |<optional parameters>|

Parameters (Required)

<time>
The desired shutdown time of the program.
<sleep_seconds>
The intervals between the verification of the program exiting with a return code.
<program_name and parameters>
The program you wish to run.

Parameters (Optional)

<stop_rc>
Stops the program if the specified return code is reached.

Return Codes

0
The program exited naturally after the return code was reached.
1
The program has reached shutdown time and is shutting down.
2
Invalid number of arguments. Check the syntax of the command line.
3
Application error with the running program.

Error Messages

  • Invalid number of arguments passed.
    Usage: ContProgRun.prl targettime sleep_seconds \"program\" stop_rc(optional)
    An invalid number of arguments was passed. Check the syntax of the command string for errors.
  • Time has expired...shutting down
    The desired shutdown time has passed. The program is shutting down.
  • Program: $program Return Code: $rc
    The program has exited with the return code.

Examples

  • ContProgRun.prl 12:00 20 quest 4
    Continuously runs a program named quest that checks every 20 seconds to see if the program returns exit code of 4 until 12:00. If time reaches 12:00 or returns a code of 4, the program will stop.


Copy.prl

Description

Copies database records from one file to another.

Command Syntax

Copy.prl <file_name> <new_file_name> <starting_point> <total_number_of_lines_to_copy>

Parameters (Required)

<file_name>
The file that you want to copy records from.
<new_file_name>
The file that you want to copy records to.
<starting_point>
The line that you want to start copying from.
<total_number_of lines_to_copy> Total number of lines after the beginning that you want to copy.

Return Codes

3
An incorrect number of arguments was passed. Make sure the command syntax is correct.
5
<file_name> doesn't exist. Check that the file exists in the specified location.
99
<file_name> is empty. Check to see if the data is in the specified file.

Error Messages

  • <File_name> is empty. Please Check!
    The specified file is empty. Check to see if data exists in the specified file.
  • <File_name> does not exist. Please Check!
    The specified file does not exist. Check to see if the file exists in specified location.
  • Usage: copy.prl filename newfilename from_point to_point
    An incorrect number of arguments was passed. Make sure the command syntax is correct.

Examples

  • Copy.prl file.txt file2.txt 23 15
    Copies line 23 through 38 of file.txt to file2.txt.

DelayedStart.prl

Description

Repetitively reruns an interface when it reaches a stable point and can be restarted.

Command Syntax

Parameters (Required)

<job_name> The job name that you wish to force a start.
<mail_alias> Allows you to receive email if the job fails.

Return Codes

0 Job force started correctly.
1 Job failed to start correctly.
2 Invalid number of arguments. Check the syntax of the command string.

Error Messages

  • Error: Invalid number of arguments
    Usage: DelayedStart.prl jobname mail_alias
    An invalid number of arguments was passed. Check the syntax of the command.
  • Error running <filename>
    Job status is <current_status>
    The above job failed to start correctly and currently is in <status>.

Examples

  • DelayedStart.prl zpmmrp1002 ops_user
    Will constantly force start for the job named zpmmrp1002. If job fails to start, an email is sent to you.

FileWatch.prl and NTFileWatch.prl

Description

Checks for the arrival of a file (with wildcard search) until a specified termination time, instead of the AutoSys term_run_time..

Command Syntax

UNIX - FileWatch.prl <File> <Time> [<optional parameters>]
Windows - NTFileWatch.prl <File> <Time> [<optional parameters>]

Parameters (Required)

<File>
Name of the file to watch for (wildcarding such as *.txt, fi*.* or * can be used)
<Time>
Termination time.

Parameters (Optional)

<sleep seconds>
Specify search interval in seconds.

Return Codes

0
The selected file was found.
1
The selected file was not found.
2
Invalid number of arguments. Make sure the syntax of the command is correct.

Error Messages

  • Invalid number of arguments.
    Usage: Filewatch.prl file time Sleep_Seconds (optional)
    Please check to make sure that the number of arguments is correct.
  • Warning: Could NOT open <path> for Read.
    The directory could not be opened. Verify that read permissions are available for this directory.
  • Time has expired...shutting down
    The desired time has passed and the file was not found.

Examples

  • Filewatch.prl file.txt 12:00 120
    UNIX - Will search for file.txt, until 12:00pm and search for the file every 120 seconds.
  • NTFilewatch.prl*.txt 08:00 60
    Windows - Will watch for the arrival of any file with a ".txt" extension, until 8:00am, and search for a file every 60 seconds.
FTPDel.prl

Description

Issues a delete command within FTP to a file and wraps error checking into the routine, printing a report if there are any errors during the deletes.

Command Syntax

FTPDel.prl <host> <id> <disk> <password> <hostfile>

Parameters (Required)

<host>
The host machine that you want the file deleted from.
<id>
The id that will be used to connect to the host machine.
<disk>
The location of the file on the host machine.
<password> The password for the id used to login to the host machine.
<hostfile>
The file that you wish to delete.

Return Codes

0
The ftp delete of the specified file completed successfully.
1
Invalid number of arguments passed. Check the syntax of the command.
3
Error during ftp command. Could be a permissions problem or file doesn't exist.

Error Messages

  • Error: invalid number of arguments passed
    Usage: FTPDel.prl host id disk password hostfile
    There was an error in the syntax of the command. Make sure the correct number of arguments was passed.
  • Error: while processing ftp_cmd
    There was an error during the ftp routine. Either you do not have sufficient rights, or the file does not exist in the specified location.

Examples

    FTPDel.prl Prod user1 /usr pass report.txt
    This will delete the file report.txt from the Prod server in the directory /usr using FTP with username user1 and password pass. Any errors in the process will be printed on a report.

FTPGet.prl

Description

Issues a get command within FTP to a file and wraps error checking into the routine, printing a report if there are any errors during the get.

Command Syntax

FTPGet.prl <host> <id> <disk> <password> <hostfile> <unixfile>

Parameters (Required)

<host>
The host machine where the desired file resides.
<id>
The id that will be used to connect to the host machine.
<disk> The location of the file on the host machine.
<password> The password for the id used to login to the host machine.
<hostfile> The file that you wish to retrieve.
<unixfile>
The filename of the file once it's on the Unix side.

Return Codes

0
The ftp get of the file desired completed successfully.
1
Invalid number of arguments passed. Check the syntax of the command.
3
Error during ftp command. Could be permissions problem.

Error Messages

  • Error: invalid number of arguments passed
    Usage: FTPGetl.prl host id disk password hostfile
    There was an error in the syntax of the command. Make sure the correct number of arguments was passed.
  • Error: while processing ftp_cmd
    There was an error during the ftp routine. The specified user may not have sufficient rights.

Examples

  • FTPGet.prl Prod user1 /usr pass report.txt report1.txt
    This will retrieve the file report.txt from the server named Prod in a directory /usr using FTP with username user1 and password pass. Once it's retrieved from the server, the file will be renamed report1.txt. Any errors in the process will return a report to you.
FTPMput.prl

Description

Issues a Mput command within FTP to a group of files with error checking and reporting. This tool allows for the transfer of an entire directory.

Command Syntax

FTPMput.prl <sleep seconds> <host> <id> <password> <disk> <source directory/Filename> [<Optional Parameter>]

Parameters (Required)

<sleep seconds>
Specifies the search interval in seconds.
<Host>
Machine name where the file will be uploaded.
<id>
Your login ID.
<Password> The password for accessing the remote host.
<disk> The drive where the file is kept.
<source directory/filename>
The directory location and name of the upload file.

Parameters (Optional)

<Backupdir>
The location of a backup directory.

Return Codes

0
The transfer was completed successfully or there are currently no files to ftp.
1
Invalid number of arguments.
3
An error occurred when processing an FTP command.
5 An error occurred when transferring the file.
7
No wildcards were found.

Error Messages

  • Transfer Complete/Successfully
    The FTP transfer was completed successfully.
  • No files to ftp at this time.
    There are currently no files to upload.
  • Error: invalid number of arguments passed.
    Please check to make sure that the number of arguments is correct.
  • Error: while processing an FTP command
    An error occurred while running an FTP command.
  • Error: $move_cmd
    An error occurred while running the move command.
  • Warning: no wildcards found!
    No files match the specified wildcard parameter.

Examples

  • FTMPut.prl - 60 Target Admin Administrator c: c:\test* d:\backup
    Connects with the machine named Target using the user name "Admin" and its password "Administrator". It then searches the local c: drive for any files beginning with "test," uploads those files to Target's c: directory and archives them into the local d:\backup directory. The system sleeps for 60 seconds between each search.
  • FTMPut.prl - 60 Target Admin Administrator /tmp /tmp/test* /backup
    Connects with the machine named Target using the user name "Admin" and its password "Administrator". It then searches the local Unix /tmp drive for any files beginning with "test," uploads those files to Target's /tmp directory and archives them into the local Unix /backup directory. The system sleeps for 60 seconds between each search.
FTPPut.prl

Description

Issues a put command within FTP to a file with error checking and reporting.

Command Syntax

IFTPPut.prl <host> <id> <disk> <password> <unix file name> <host file>

Parameters (Required)

<Host>
Machine name where the file will be uploaded.
<id> Your login ID.
<Disk> The drive where the file is kept.
<Password> The password for accessing the remote host.
<Unix Filename> The file name of the downloaded FTP file.
<Host file>
The name of the file on the target machine.

Return Codes

0
The upload was completed successfully.
1
Invalid number of arguments.
3
Error occurred while processing an FTP command.

Error Messages

  • Transfer Complete/Successfully
    The FTP transfer was completed successfully.
  • Error: invalid number of arguments passed.
    Please check to make sure that the number of arguments is correct.
  • Error: while processing an FTP command
    An error occurred while running an FTP command.

Examples

  • IFTPGet.prl Target Admin d:\ pswd /tmp/input.ftp output.ftp
    Connects with the remote machine named Target and accesses the output.ftp file in Target's d: drive using the password pswd. Transfers ftp file to the UNIX server/system (/tmp directory) and names the file "input.ftp".
HeaderWatch.prl

Description

Checks the name of a file header until it changes or a shutdown time is specified. Useful in checking to see if a filename has changed within a specified time.

Command Syntax

HeaderWatch.prl <filename> <string> <target shutdown time> [<optional parameters>]

Parameters (Required)

<filename>
The name of the file with the desired header string.
<string>
Specifies the header string that you wish to watch.
<target shutdown time>
The desired shutdown time.

Parameters (Optional)

<sleep seconds>
Specifies the search interval in seconds.

Return Codes

0
The header containing the specified string was found.
1
Time has expired. The shut down time is given in seconds.
2
Invalid number of arguments.

Error Messages

  • String was Found.
    The header containing the specified string has been located.
  • Time has expired..Shutting down /n
    The search time has expired and the search process will shut down in n seconds.
  • Error: invalid number of arguments passed.
    Please verify that the number of arguments is correct.
  • Time already expired - assume the present file will wait 1 minute.
    The search time has expired and the search process will wait 1 minute before shutting down.

Examples

  • HeaderWatch.prl c:\output.jil test 13:00 60
    Searches the output.jil file in the c: directory for the "test" string in the header. The process will shut down at 1pm and each search will restart after 60 seconds of sleep time.
  • HeaderWatch.prl /tmp/output.jil test 13:00 60
    Searches the output.jil file in the /tmp directory for the "test" string in the header. The process will shut down at 1pm and each search will restart after 60 seconds of sleep time.
ISQL.prl

Description

Simulates SQL, but gives better error reporting and can automate the SQL process.

Command Syntax

ISQL.prl <Entire ISQL statement>

Parameters (Required)

<Entire ISQL Statement>
The entire ISQL statement.

Return Codes

0
ISQL was successfully simulated.
2
Shows the ISQL statement is in use.
> 8
An ISQL error/command.

Error Messages

  • Completed
    The simulation was successful.
  • Usage: ISQL.prl ISQL Statement
    Verifies that the ISQL statement that was sent.

Examples

  • ISQL.prl c:\input
    Simulates the ISQL command of c:/input.
  • ISQL.prl /tmp/input
    Simutlates the ISQL command of /tmp/input.

Rcp.prl

Description

Copies (rcp) files from one directory to another on a remote machine. Wraps the rcp command with error checking to make sure the program exits properly and prints a report if errors occur.

Command Syntax

Rcp.prl <Full Directory path or file> <MACHINE>:<directory> <MACHINE>:<directory> <MACHINE>:<directory>

Parameters (Required)

<Full Directory path or File>
The path of the directory or file to be transferred to multiple locations on multiple machines.
<MACHINE>
Each of the servers the script will attempt to transfer the file(s) to.
<directory>
The directory for the <MACHINE> that specifies where the file(s) should be placed.

Return Codes

0
This script successfully sent the files to the multiple speicifed locations.
1
Invalid Number of Arguments.
3
Invalid destination specified.
5
Remote copied failed.

Error Messages

  • Error: invalid number of arguments passed.
    Look at the command syntax to verify that all of the arguments were passed correctly.
  • Error: Invalid Destination parameter.
    One of the destinations that was selected had incorrect syntax.
  • Error during rcp of files.
    This message will appear with the destination of the problematic file.

Examples

  • Rcp.prl C:\temp\ SAL 23:/tmp/out/ PRD_FIN_6:/tmp/out/
    Sends all the files in the C:\temp\ directory to the server SAL 23, the directory /tmp/out/, the server PRD_FIN_6 and the directory /tmp/out/.
ResetJils.prl

Description

Resets all JIL to INACTIVE. Also verifies that a job is not ON_ICE. If ON_ICE, the program asks if you would still like to place job ON_ ICE.

Command Syntax

ResetJils.prl <Server> <DataBase Server> <File> [<optional parameters>]

Parameters (Required)

<Server>
The machine that you are logged into that has an AutoSys Client installed.
<DataBase Server>
The machine that has the AutoSys database installed.
<File>
The full path of the file that contains the status of each job before resetting to INACTIVE.

Parameters (Optional)

<Job Name Pattern>
Using the AutoSys wildcard, the script will only select the jobs that match the name pattern to place INACTIVE.

Return Codes

0
The jobs in AutoSys were all set to INACTIVE and the previous job STATUS was saved in <FILE>.
1
Invalid Number of Arguments.
3
Not Authorized to perform this task.
5 Host Machine is Invalid.
7 Source File Does not exist.
9
Error while running SQL step.

Error Messages

  • Error: invalid number of arguments passed.
    Check the command syntax to verify that all of the arguments were passed correctly.
  • Error: Only autoedit can perform this routine!
    Autoedit is the only user authorized to run this script.
  • Warning: hostname is Invalid!
    This server does not have AutoSys installed, please run this script on an AutoSys client or server machine.
  • Error: source File doesn't exist.
    The output file could not be opened or does not exist.
  • Error: while performing sql on server.
    There was a problem performing the select statement from the Database, please ensure all authorities are correct.

Examples

  • ResetJils.prl MACHINE DbMACHINE C:\output.txt
    MACHINE is the server you are running the script from. The DbMachine is where the AutoSys DataBase resides. All the jobs are set to INACTIVE and the previous status of all jobs is saved to C:\output.txt.
  • ResetJils.prl MACHINE DbMACHINE C:\output.txt IA%
    MACHINE is the server you are running the script from. The DbMachine is where the AutoSys DataBase resides. All the jobs whose names begin with IA are set to INACTIVE and the previous status of all these jobs is saved to C:\output.txt.

Sname.prl

Description

Substitutes a given string within a file name. Renames the old file with an .old extension if desired.

Command Syntax

Sname.prl <File> <Old String> <New String>

Parameters (Required)

<File>
The full path of the file affected by the string substitution.
<Old String>
The old string to be replaced in the <File>.
<New String>
The new string to replace the <Old String> in <File>.

Return Codes

0
This script successfully sent the message that you listed in the input file.
1
Invalid number of arguments.
3
The file does not exist or cannot be written to.

Error Messages

  • ERROR: invalid number of arguments passed.
    Check the command syntax to verify that all of the arguments were passed correctly.
  • <File> does not exist or can't be written to, please check.
    The File cannot be written to or does not exist. Please check the file permissions.

Examples

  • Sname.prl C:\data.txt receivable received
    Changes the string receivable to received in the file C:\data.txt.
  • Sname.prl /tmp/data.txt receivable received
    Changes the string receivable to received in the file /tmp/data.txt.

TimedRun.prl

Description

Cleanly shutsdown processes at a specific time. If process ends early, it assumes there is a problem and provides an exit code in an error report.

Command Syntax

TimeRun.prl <Timeout Setting> <Command>

Parameters (Required)

<Timeout Setting>
The time, in hours:minutes format, before which the command should not complete.
<Command>
The command to execute.

Return Codes