HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: RE: Assigning a Variable to a search
Operating System - HP-UX
1837900
Members
3171
Online
110123
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2000 09:39 AM
10-30-2000 09:39 AM
RE: Assigning a Variable to a search
I'm using Perl to do a search within OpenMail for our users and once this search feature is made, I want the output to be assigned a variable. What's the best way to do this in Perl?
"Sleep, who needs sleep?"
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2000 11:27 AM
10-30-2000 11:27 AM
Re: RE: Assigning a Variable to a search
I assume you want to assign the return of your command to a variable, rather that the other way around (your wording suggested this). Try this:
$YOURVARIABLE = `your_command`
The backticks work like they do with shell programming, including variable expansion.
$YOURVARIABLE = `your_command`
The backticks work like they do with shell programming, including variable expansion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2000 11:52 AM
10-30-2000 11:52 AM
Re: RE: Assigning a Variable to a search
John, basically, I'm looking through a string of information and ignoring the first 3 characters and need to pull the next 5 characters as the system UID #. In order to do a password reset function in OpenMail, I grab this UID # according to the name information that the user inputs on the form.
This is what I have so far:
$UID=qx(/opt/openmail/bin/omshowu -n $first_name $middle_name $last_name $genqua
l |grep System |awk -F":" '{print $2}'|awk -F" " '{print $1}');
But, I need to somehow capture the next 5 characters as the UID on every user on this server. Any idea?
Best Regards,
Michael Funke
This is what I have so far:
$UID=qx(/opt/openmail/bin/omshowu -n $first_name $middle_name $last_name $genqua
l |grep System |awk -F":" '{print $2}'|awk -F" " '{print $1}');
But, I need to somehow capture the next 5 characters as the UID on every user on this server. Any idea?
Best Regards,
Michael Funke
"Sleep, who needs sleep?"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2000 01:15 AM
10-31-2000 01:15 AM
Re: RE: Assigning a Variable to a search
Micheal,
what is the output of the omshowu command with the args as supplied?
I'm afraid, we're not using Openmail, that's why I neither know the command nor its output.
But I know a bit of Perl, and possibly could help you with the parsing of the output.
Meanwhile just some general suggestions.
If you are expecting large chunks of output from a command, it's preferable not to use the backticks, system, or qx calls but rather pipe it into a while loop because it keeps the stack small for each line is swallowed sequentially.
e.g.
open OMSHOWU, "/opt/openmail/bin/omshowu arg1 arg2 |" || die "couldn't pipe: $!\n";
while () {
# parse lines here
}
close OMSHOWU;
Then if already using Perl I wouldn't want to rely on something inferior like awk.
The regex and parsing features are much superior to anything else.
That's why Perl once was thought up. ;-)
If you use backticks, don't forget to do a chop or chomp afterwards because usually you want to get rid of the record separator \n.
Gathering from your awk field separators (i.e. ":") I assume the format is similar to that of /etc/passwd, which would make things fairly easy.
Have you had a look at CPAN yet?
Maybe someone has already come up with a module to parse OpenMail output/databases.
Then I'd strongly advise to make use of such a module.
what is the output of the omshowu command with the args as supplied?
I'm afraid, we're not using Openmail, that's why I neither know the command nor its output.
But I know a bit of Perl, and possibly could help you with the parsing of the output.
Meanwhile just some general suggestions.
If you are expecting large chunks of output from a command, it's preferable not to use the backticks, system, or qx calls but rather pipe it into a while loop because it keeps the stack small for each line is swallowed sequentially.
e.g.
open OMSHOWU, "/opt/openmail/bin/omshowu arg1 arg2 |" || die "couldn't pipe: $!\n";
while (
# parse lines here
}
close OMSHOWU;
Then if already using Perl I wouldn't want to rely on something inferior like awk.
The regex and parsing features are much superior to anything else.
That's why Perl once was thought up. ;-)
If you use backticks, don't forget to do a chop or chomp afterwards because usually you want to get rid of the record separator \n.
Gathering from your awk field separators (i.e. ":") I assume the format is similar to that of /etc/passwd, which would make things fairly easy.
Have you had a look at CPAN yet?
Maybe someone has already come up with a module to parse OpenMail output/databases.
Then I'd strongly advise to make use of such a module.
Madness, thy name is system administration
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP