- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- ksh scripting to perl
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
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
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- 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
тАО09-07-2005 02:26 AM
тАО09-07-2005 02:26 AM
following from ksh script.
owner=`ll t | awk '{print $3}'`
cat data.file | mailx -s "Data" $owner
I am not having much luck and cannot find
any examples in the book to do the equivalent.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2005 02:39 AM
тАО09-07-2005 02:39 AM
Solution$owner = `ls -l t |awk'{print $3}';
`cat data.file |mailx -s "Data" $owner`;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2005 02:43 AM
тАО09-07-2005 02:43 AM
Re: ksh scripting to perl
perl -e '$uid=(stat "x")[4]; $name=getpwuid $uid; open OU,"|mailx -s Data $name"; open IN,"
Here I started the mail process through an open, piping data into it.
Alternatives are 'system()', fork, backtick,....
hth,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2005 03:54 AM
тАО09-07-2005 03:54 AM
Re: ksh scripting to perl
in the commands as you described. But for
some reason the "awk" part does not get
executed and I end up with $owner being the
total line from the "ll" command and mailx
trying to send to each field listing from
the "ll" listing.
Hein van den, Your syntax does not show
any errors but it does not do anything.
I did change x to t for file name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2005 04:12 AM
тАО09-07-2005 04:12 AM
Re: ksh scripting to perl
I think Hein meant something like:
# perl -e '$x="/etc/hosts";$uid=(stat $x)[4];$name=getpwuid $uid;open OU,"|mailx -s Data $name";open IN,"<",$x;print OU $_ while
...or slightly more generalized to use a filename as an argument:
# perl -e '$uid=(stat $ARGV[0])[4];$name=getpwuid $uid;open OU,"|mailx -s Data $name";open IN,"<",$ARGV[0];print OU $_ while
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2005 04:13 AM
тАО09-07-2005 04:13 AM
Re: ksh scripting to perl
foreach $LINE (`ls -l *.dat`) {
chomp $LINE;
@LINE = split " ", $LINE;
`cat $LINE[8] |mailx -s Data $LINE[2]`;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2005 04:20 AM
тАО09-07-2005 04:20 AM
Re: ksh scripting to perl
Jerry, Hein's original solution DID WORK just fine if you merely substitute the name of your file for "x". My first cut-and-paste of it mangled it. The credit is his!
Regards!
...JRF...
/* no points please */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2005 05:20 AM
тАО09-07-2005 05:20 AM
Re: ksh scripting to perl
James is correct, I (over?) simplified the example to test for and send out the same file called "x". I assumed you needed changes anyway to pass in particular file names.
A little more clear perhpas by spreading it out in a script, and using your file names:
(untested)
$uid=(stat "t")[4];
$name=getpwuid $uid;
open OU,"|mailx -s Data $name";
open IN,"
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2005 08:12 AM
тАО09-07-2005 08:12 AM
Re: ksh scripting to perl
'$uid=(stat "x")[4]; $name=getpwuid $uid; open OU,"|mailx -s Data $name"; open IN,"
did not work for me is because of the begin
' and end '
When I took them out it worked.
It's back to the perl books. I have been
assimilated by ksh too long.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-08-2005 02:22 AM
тАО09-08-2005 02:22 AM
Re: ksh scripting to perl
It runs but I am getting this error message
on one line. The line is:
my $name=getpwuid ($uid);
The error message is:
Use of uninitialized value in getpwuid at script1 line 33.
Why??
The script is enclosed if anyone wants to
use it, look at it. The code given by all
here was used in a script I wrote using the perl Net::FTP module.
It was the only was I could trap error messages.