পৃষ্ঠাসমূহ

Search Your Article

CS

 

Welcome to GoogleDG – your one-stop destination for free learning resources, guides, and digital tools.

At GoogleDG, we believe that knowledge should be accessible to everyone. Our mission is to provide readers with valuable ebooks, tutorials, and tech-related content that makes learning easier, faster, and more enjoyable.

What We Offer:

  • 📘 Free & Helpful Ebooks – covering education, technology, self-development, and more.

  • 💻 Step-by-Step Tutorials – practical guides on digital tools, apps, and software.

  • 🌐 Tech Updates & Tips – simplified information to keep you informed in the fast-changing digital world.

  • 🎯 Learning Support – resources designed to support students, professionals, and lifelong learners.

    Latest world News 

     

Our Vision

To create a digital knowledge hub where anyone, from beginners to advanced learners, can find trustworthy resources and grow their skills.

Why Choose Us?

✔ Simple explanations of complex topics
✔ 100% free access to resources
✔ Regularly updated content
✔ A community that values knowledge sharing

We are continuously working to expand our content library and provide readers with the most useful and relevant digital learning materials.

📩 If you’d like to connect, share feedback, or suggest topics, feel free to reach us through the Contact page.

Pageviews

Monday, February 6, 2017

Rexx - System Commands

One of the biggest advantages in Rexx is the ability to create re-usable scripts. Often in organizations nowadays, having re-usable scripts is a big value add in saving time to do common repetitive tasks.
For example, technology teams in an IT organization can have the need to have scripts which do common everyday tasks.
These tasks can include interacting with the operating systems. These scripts can then be programmed to handle bad return codes or errors.
Rexx offers a lot of system commands that can be used to perform such repetitive tasks. Let’s look at some of the system commands available in Rexx.

dir

This is the normal directory listing command which is used in Windows.

Syntax

dir

Parameters

None

Return Value

This method returns the current directory listing on the system.

Example

/* Main program */ 
dir 
The output depends on the directory in the system.
The following program is just an example.

Output

Volume in drive D is LENOVO 
Volume Serial Number is BAC9-9E3F  
Directory of D:\ 
04/06/2016  12:52 AM           268,205 100008676689.pdf 
10/20/2015  08:51 PM    <DIR>          data 
06/01/2016  10:23 AM                31 Example.txt 
10/28/2014  06:55 PM    <DIR>          Intel 
06/02/2016  11:15 AM                23 main.rexx 
12/22/2014  08:49 AM    <DIR>          PerfLogs  
12/13/2015  11:45 PM    <DIR>          Program Files 
12/24/2015  10:26 AM    <DIR>          Program Files (x86) 
07/17/2015  01:21 AM    <DIR>          Users 
12/23/2015  10:01 AM    <DIR>          Windows 
               3 File(s)        268,259 bytes 
               7 Dir(s)     202,567,680 bytes free 
Another example of the dir command is shown in the following program. Only this time we are making use of the special rc variable. This variable is special in Rexx and gives you the status of the execution of system commands. If the value returned is 0, then that means the command is executed successfully. Else the error number will be given in the rc variable name.

Example

/* Main program */ 
dir 
if rc = 0 then 
   say 'The command executed successfully' 
else 
   say 'The command failed, The error code is =' rc 
When we run the above program we will get the following result.

Output

The command failed, The error code is = 127 

Redirection Commands

Rexx also has the facility of using redirection commands. The following redirection commands are available in Rexx.
  • < − This command is used to take in the input which comes from a file.
  • > − This command is used to output the content to a file. If the file does exist, it will be over-written.
  • >> − This is also used to output the content to a file. But the output is added to the end of the file to preserve the existing content of the file.
Let’s look at an example of how we can use redirection commands. In the following example, we are using the sort command to sort a file called sortin.txt. The data from the file is sent to the sort command. The output of the sort command is then sent to the sortout.txt file.

Example

/* Main program */ 
'sort <sortin.txt> sortout.txt' 
Assume that the file sortin.txt has the following data.

Output

b 
c 
a
The file sortout.txt will then have the following data.
a 
b 
c 

The ADDRESS Function

This method is used to find out what is the default environment used for the Input, Error and Output streams.

Syntax

ADDRESS(options) 

Parameters

  • Options for what is the address of a particular system.

Return Value

This method returns the name of the environment for the Input, Error and Output streams.

Example

/* Main program */ 
say ADDRESS('I') 
say ADDRESS('O') 
say ADDRESS('E')
When we run the above program we will get the following result.

Output

INPUT NORMAL 
REPLACE NORMAL 
REPLACE NORMAL

No comments:

Post a Comment