04
Mon, Nov
5 New Articles

TechTip: Trees Are Good for Climbing and More

Programming - Other
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

The “tree” command can quickly show you the structure of an IFS directory, but it’s not installed in PASE by default. Learn how to get it.

My days are in large part spent in the PASE environment on IBM i. PASE is based on AIX, and both are Linux-like in their abilities, though PASE does not contain many commands and utilities that I'd consider on the "need" list. Sometimes I'm also doing things on Linux systems and get exposed to utilities and commands that I then desire to have on PASE. Such was the case the other day when I was writing my "PASE Intro" lab for COMMON Spring 2017. I needed to print out a directory listing of parent and child directories, and I knew the Linux “tree” command would foot the bill. Well, I quickly learned it didn't exist in PASE, so this article will convey the steps I took to get it onto PASE.

First things first. Here's how I check to see if a given command exists in PASE on IBM i.

$ which tree

tree not found

As you can see, the PASE environment wasn't able to locate a command named "tree." I can determine all the locations in which it looked for the command by displaying the directories the command was searched for.

$ echo $PATH

/QOpenSys/usr/bin:/usr/ccs/bin:/QOpenSys/usr/bin/X11:/usr/sbin:.:/usr/bin:/home/AARON/bin

Above is a colon-delimited set of directories that are searched every time you type a command into a PASE shell. If the command exists in a directory that isn't in the PATH environment variable, then it won't be found. I won't go further with that rabbit trail; instead, let's continue the pursuit of obtaining the tree command.

The first place I search for Linux-like utilities is the perzl.org/aix site. Michael Perzl has ported many Linux utilities to AIX. I click on the Available Packages link, type Ctrl+F on that page, and do a search for "tree." I am relieved to find it and click on the tree command's link to learn whether there are dependencies. Sure enough, it has the dependency of libgcc >= 4.2.3. I used to fret when I saw "gcc" because that often meant a long afternoon of trying to figure stuff out. Not so anymore with the IBM i Chroot project, which has a the pkg_perzl_gcc-4.8.3.lst package configuration, which includes libgcc. In article "IFS Containers Part 3, Installing Open Source from the Internet," I showed how to obtain and install the IBM i Chroot tooling, so I won't be covering that here. Instead, I will just give you the command necessary to install pkg_perzl_gcc-4.8.3.lst.

$ cd /QOpenSys/ibmichroot/pkg

$ pkg_setup.sh pkg_perzl_gcc-4.8.3.lst

At this point, we have libgcc installed because it was included in the pkg_perzl_gcc-4.8.3.lst dependencies. The next thing I did was to check other .lst files in the IBM i Chroot project to see if any of them had the tree command. I came up empty-handed, and that means a manual install. A manual install isn't so bad, just a few extra steps.

First I go to the pkg_setup.sh script in the IBM i Chroot project because I know that's where the rpm command exists, and I obtain the following line.

rpm --ignoreos --ignorearch --nodeps --replacepkgs -hUv $base

This command is exactly what I want minus the $base at the end, which is a shell script variable. I need to replace $base with the tree rpm file, which doesn't yet exist on my IBM i. To obtain the tree rpm, I go back to the tree command's page on perzl.org and right-click on tree-1.6.0-1.aix5.1.ppc.rpm to obtain the underlying link, which is http://www.oss4aix.org/download/RPMS/tree/tree-1.6.0-1.aix5.1.ppc.rpm. I then go to my PASE shell and enter the following commands.

$ cd /QOpenSys/ibmichroot/pkg

$ wget http://www.oss4aix.org/download/RPMS/tree/tree-1.6.0-1.aix5.1.ppc.rpm

$ rpm --ignoreos --ignorearch --nodeps --replacepkgs -hUv tree-1.6.0-1.aix5.1.ppc.rpm

The wget command is included with the IBM i Chroot project and is used to retrieve the tree rpm from perzl.org. Next, I use the rpm command to install the tree rpm file. At this point, the tree command is installed, and I can double-check by running the same which command again.

$ which tree

/QOpenSys/usr/bin/tree

Note that /QOpenSys/usr/bin/tree is only a symbolic link and not where the actual tree command is stored. A symbolic link is like a desktop shortcut in Windows. To see more details about /QOpenSys/usr/bin/tree, I can pipe the results of which to the ls command.

$ which tree | xargs ls -al

lrwxrwxrwx   1 usrz8igs 0               54 Jan 6 17:02 /QOpenSys/usr/bin/tree

-> ../../opt/freeware/bin/tree

Yahoo! Er, I mean, Altaba!

Now I can start making use of the tree command. Below I am telling it to give me a tree representation starting at the root of the IFS. The -d option is declaring to only list directories, and -L says to only go two levels deep.

$ tree / -d -L 2                                    

/                                                                              

|-- QOpenSys                                                                  

|   |-- QIBM                                                                  

|   |-- bin -> /QOpenSys/usr/bin                                              

|   |-- lib -> /QOpenSys/usr/lib                                              

|   |-- opt                                                                    

|   |-- sbin -> /QOpenSys/usr/sbin                                            

|   `-- usr                                                                    

|-- bin -> /QOpenSys/usr/bin                                                  

|-- dev                                                                        

|   `-- pts                                                                    

|-- etc                                                                        

|   |-- X11                                                                    

|   `-- skel                                                                  

|-- home                                                                      

|   `-- USRZ8IGS                                                              

|-- lib -> /QOpenSys/usr/lib                                                  

|-- opt -> /QOpenSys/opt                                                        

|-- sbin -> /QOpenSys/usr/sbin                                                

|-- tmp                                                                        

|-- usr                                                                        

|   |-- bin -> /QOpenSys/usr/bin                                              

|   |-- include -> /QOpenSys/usr/include                                      

|   |-- lib -> /QOpenSys/usr/lib                                              

|   |-- linux                                                                  

|   |-- sbin -> /QOpenSys/usr/sbin                                            

|   `-- share -> /QOpenSys/usr/share                                          

`-- var

I hope this article was beneficial to you. My goal is to convey and teach my approach to things I come across in PASE. Hopefully, this lessens how uncomfortable PASE can initially be when you're first learning about it.

If you have any questions or comments, then please comment below or email me at This email address is being protected from spambots. You need JavaScript enabled to view it..

Aaron Bartell

Aaron Bartell is Director of IBM i Innovation for Krengel Technology, Inc. Aaron facilitates adoption of open-source technologies on IBM i through professional services, staff training, speaking engagements, and the authoring of best practices within industry publications andwww.litmis.comWith a strong background in RPG application development, Aaron covers topics that enable IBM i shops to embrace today's leading technologies, including Ruby on Rails, Node.js, Git for RPG source change management, and RSpec for unit testing RPG. Aaron is a passionate advocate of vibrant technology communities and the corresponding benefits available for today's modern application developers. Connect with Aaron via email atThis email address is being protected from spambots. You need JavaScript enabled to view it..

Aaron lives with his wife and five children in southern Minnesota. He enjoys the vast amounts of laughter that having a young family brings, along with camping and music. He believes there's no greater purpose than to give of our life and time to help others.

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: