- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Pass a variable via ftp
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
Forums
Discussions
Discussions
Discussions
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
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
02-12-2002 09:44 AM
02-12-2002 09:44 AM
I have passed variables from hp-ux to the mainframe, but not the other way around.
Of course I could call a scipt to pass a variable on a fixed basis, but I would rather not have to code multiple scipts just to cover all the possible values for the variable.
Thanks for any input.
dl
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2002 10:01 AM
02-12-2002 10:01 AM
SolutionMy answer to this would be to write a script to
write an FTP script.
I don't know if Perl is available on your mainframe but that would be my weapon of choice; you also get FTP error checking free of charge. Of course, you can reverse the sense of the operations and let HP-UX do a put or get as needed.
In the past, I used to do this stuff in the shell but now I NEVER do because I have found a much cleaner way to do it that makes error trapping duck soup. Do this stuff in Perl using the Net::FTP module which is available from http://www.cpan.org .
Here's how simple it can be:
#!/usr/bin/perl -w
use English;
use Net::FTP;
use strict;
my $ftp = Net::FTP->new("remotehost",Debug => 0);
$ftp->login("cstephen","top_secret");
$ftp->cwd("/tmp");
$ftp->get("myfile");
my $stat = $ftp->status;
my $full_stat = $ftp->code;
# $stat contains the first digit; usually all
# that you need to do is test if it is equal
# to 2. $full_stat contains the full 3-digit
# value but is seldom needed
printf("Status: %d Full Status: %d\n",$stat,$full_stat);
# Sample Test
if ($stat == 2)
{
print "Get was good\n";
}
else
{
print "Get was bad\n";
}
$ftp->quit;
In the above example, suppose that we wanted to replace the hard-coded "myfile" with a value
determined at run time by reading the command line.
my $filename = $ARGV[0];
shift;
We then replace the "myfile" with the variable and we are done.
$ftp->get($filename);
Notice that this method easily handles the error checking. If you like, you can use the shell for most of your script and simply use a bit a perl for the actual FTP transfers. In that case add the statement exit($stat) to the perl script and then your shell script does have a valid status indication.
Regards, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2002 10:15 AM
02-12-2002 10:15 AM
Re: Pass a variable via ftp
First let me say I would give you a 10 right now, just for the info you passed, if it didn't indicate the question was resolved. So hold on.
No, perl is not available from the mainframe.
What I need to do is pass a date mmddyy to a unix script that could be most any date.
I can call a script easily enough or have a script get a file from the mainframe but I realy only want to call the unix script and pass a given date.
Thanks.
dl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2002 10:23 AM
02-12-2002 10:23 AM
Re: Pass a variable via ftp
Are you attempting to get a file with a certain date name??
echo "Enter date file name: \c"
read "name"
ftp -i -n <
user joe password
ascii
get ${name}
by
EOF
?????
Hope this helps
...jcd...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2002 10:29 AM
02-12-2002 10:29 AM
Re: Pass a variable via ftp
I have no problem in the area you mention.
I need to
ftp "unix_box"
username
passwd
"Pass_variable" >> unix_script
Thanks for the input though.
dl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2002 10:43 AM
02-12-2002 10:43 AM
Re: Pass a variable via ftp
Sorry, I miss read.
The only way I can think of with ftp would be to append.
Create a file on the mainframe with the variable.
ftp unix.box
joe
password
as
append main.file unix.script
by
?????
I know nothing of mainframe, so Hope this helps.
...jcd...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2002 12:48 PM
02-12-2002 12:48 PM
Re: Pass a variable via ftp
Since you didn't mention what OS your mainframe is running, I don't know how to script what you describe. Plan B. Set up a cronjob on the UNIX to periodically ftp to the mainframes (using Perl, of course) and look for the presense of a parameter file. If it's there get the file otherwise simply exit. If the paramter file was found, use it to build the script to get the real data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2002 01:02 PM
02-12-2002 01:02 PM
Re: Pass a variable via ftp
The OS is VM/VSE.
I'm moving in the direction you describe.
I can create a file with the
required variable and then insert this in the unix script using another script.
Unfortunately, this is not as clean as just passing the variable.
Scanning VSE for a file would
not be as viable as simply sending the variable at the time I want VSE to execute the unix script. (Execution of the script is dependent upon completion of a VSE job.)
Still Plugging in there.
This looks like a good one.
Will close out when I get something satisfactory to work
and pass on the results.
Thanks for all the input.
d
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2002 05:25 PM
02-12-2002 05:25 PM
Re: Pass a variable via ftp
even the ftp-client on your OS should have something like the ".netrc" feature, i.e. a to automate some actions (even M$ has it ;-).
Check your documentation for "netrc" or such...
Then you could create that file containing whatever you want immediately before calling "ftp"...
HTH,
Wodisch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2002 05:28 PM
02-12-2002 05:28 PM
Re: Pass a variable via ftp
Here's what I have settled on:
1. Create a sequential file on the mainframe containing the date needed.
2. Send the file from mainframe to unix.
3. Unix executable script reads into a variable the contents of the file sent from the mainframe.
Not the cleanest I would want, but slightly liveable.
Thanks for all the great input.
dl