- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- any insight into SCP question??
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-20-2006 01:00 AM
02-20-2006 01:00 AM
I have an expect script that I have that uses
scp to move files from one server to another, it is a transactional thing that I put in cron to run every 15 minutes.. I am getting a message in the mailbox:
CRONTAB LINE:
1,14,30,45 * * * * /usr/local/bin/apphire.sh
MAIL MESSAGE:
spawn /usr/local/bin/scp /tmp/*apphire.txt root@205.202.254.91:/tmp
Executing ssh2 failed. Command:' ssh2 -l root -x -a -o passwordprompt %U@%H's password: -o nodelay yes -o authenticationnotify yes
'No such file or directory'
send: spawn id exp3 not open
while executing
"send "PASSWORD\r""
(file "/usr/local/bin/appput.exp" line 4)
I can run it manually without error.
APPPUT.EXP
# cat appput.exp
###############################################
#!/usr/local/bin/expect
spawn /usr/local/bin/scp /tmp/*apphire.txt user@
expect "user@
send "PASSWORD\r"
expect "debug: uninitializing event loop"
send "\r"
###############################################
THIS IS THE SCRIPT THAT INITIATES THE PROCESS
NOTE /usr/local/bin/appput.exp Initiate at the end of the script..
APPHIRE.SH
###############################################
# cat apphire.sh
#!/bin/sh
for dst in `cat /pei/peitools/bin/distid.txt`
do
echo $dst
export D="$dst"
export INFORMIXSERVER=pei
sed s/DIST/"$D"/g /usr/local/bin/apphire.template > /tmp/"$D"apphire.sql
sudo -u support /usr/informix/bin/isql "$D"plus < /tmp/"$D"apphire.sql
done
/usr/local/bin/appput.exp
How would I assure myself the file transfer is completing correctly? Again I can run the file manually and get the following output:
# apphire.sh
arl
0 row(s) unloaded.
blr
0 row(s) unloaded.
con
0 row(s) unloaded.
elk
0 row(s) unloaded.
esu
0 row(s) unloaded.
ftc
0 row(s) unloaded.
grt
0 row(s) unloaded.
mps
12 row(s) unloaded.
plk
0 row(s) unloaded.
plv
61 row(s) unloaded.
raa
0 row(s) unloaded.
raf
0 row(s) unloaded.
ral
0 row(s) unloaded.
val
0 row(s) unloaded.
wat
0 row(s) unloaded.
wsf
0 row(s) unloaded.
wst
0 row(s) unloaded.
spawn /usr/local/bin/scp /tmp/*apphire.txt user@
user@
arlapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
blrapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
conapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
elkapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
esuapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
ftcapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
grtapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
mpsapphire.txt | 336B | 0.3 kB/s | TOC: 00:00:01 | 100%
plkapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
plvapphire.txt | 1.4kB | 1.4 kB/s | TOC: 00:00:01 | 100%
raaapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
rafapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
ralapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
valapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
watapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
wsfapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
wstapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
send: spawn id exp4 not open
while executing
"send "\r"
"
(file "/usr/local/bin/appput.exp" line 6)
Any insights appreciated..
Rex Mueller - Educational Service Unit #3
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2006 01:26 AM
02-20-2006 01:26 AM
SolutionTwo things,
You can't set any ENV variables inside cron. I think, you have some ENV that causes the execution success when you run from Shell. Check that out.
Also, make sure you use SecureShell from HP which can be downloaded from,
http://h20293.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=T1471AA
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2006 01:28 AM
02-20-2006 01:28 AM
Re: any insight into SCP question??
running SSH Secure Shell 2.3.0 (non-commercial version) on hppa2.0w-hp-hpux11.00
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2006 01:45 AM
02-20-2006 01:45 AM
Re: any insight into SCP question??
Full path is alright, how abt the ENV variables ? Did you check your shell for any special variables ?
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2006 02:03 AM
02-20-2006 02:03 AM
Re: any insight into SCP question??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2006 02:05 AM
02-20-2006 02:05 AM
Re: any insight into SCP question??
Yes, you can do it within any script, but when it runs from cron, it wont take any of these ENV variables.
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2006 02:15 AM
02-20-2006 02:15 AM
Re: any insight into SCP question??
the mail message is different today.. Not sure what changed. but I don't get the same error ..
I need to look closer at it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2006 02:34 AM
02-20-2006 02:34 AM
Re: any insight into SCP question??
It seems the OP already understand this, but just to make sure it's clear: You certainly can (and usually must) set environment variables in scripts run via cron. The scripts run via cron start out with a very limited envrionment; however, there is absolutely nothing preventing the script author from updating that environment from within the script.
How do you think Oracle scripts work from cron without that ability?
Doug
------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2006 03:28 PM
02-20-2006 03:28 PM
Re: any insight into SCP question??
I think you might want to fully path the "sudo" command in apphire.sh
cron runs its jobs with not only a very limited environment, but also with a very limited $PATH (something like /bin:/usr/bin IIRC - man crontab for details)
I can't tell, but I am assuming that your /tmp/"$D"apphire.sql scripts create /tmp/"$D"apphire.txt
If your apphire.sh script can't find sudo, it won't create /tmp/"$D"apphire.txt which looks to be the file that your "expect" script cannot find.
Good luck.
P.S. Have you looked into keybased authentication for the SCP transfers? That could radically simplify the script and allow you to remove the reliance on a hard-coded password. Just a thought.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2006 01:48 AM
02-21-2006 01:48 AM
Re: any insight into SCP question??
I used an expect script but if I could figure out how to make the key/auth stuff work in the hand shake I agree it would eliminate the expect portion of the script.
Any insights appreciated on how to do that,
the primary "Source" is HP/UX 11.0 running
SSH Secure Shell 2.3.0 (non-commercial version) on hppa2.0w-hp-hpux11.00
The primary "Target" is Fedora FC4
OpenSSH_4.0p1, OpenSSL 0.9.7f 22 Mar 2005
I am open to suggestions on this..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2006 02:00 AM
02-21-2006 02:00 AM
Re: any insight into SCP question??
What does the mail message say? Can you run SSH server in debug mode and verify what goes wrong ?
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2006 02:03 AM
02-21-2006 02:03 AM
Re: any insight into SCP question??
Sometimes it indicates it can't connect.. I know the connection exists..
Oops. Just thought of something, my backup timing. I just changed the cron job to remove any potential problems with conflicting with the Backup.
Rex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2006 02:48 AM
02-21-2006 02:48 AM
Re: any insight into SCP question??
You said, I know the connection exists.. .. How did you make sure the connection exists? Also, did you run the SSH server in debug mode to make sure it connected.
What does your # crontab -l say ?
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2006 03:02 AM
02-21-2006 03:02 AM
Re: any insight into SCP question??
I would like to eliminate the expect script and use SSH auth/key exchange.. Just need to figure out how.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2006 07:42 AM
02-21-2006 07:42 AM
Re: any insight into SCP question??
Try this site - http://mikeage.net/content/tips/linux/sshkeys.php
I'm not just brushing you off with an RTFM, the above site describes far better than I can, exactly how to set up key-based authentication for both Secure Shell SSH and OpenSSH.
Enjoy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2006 02:44 PM
02-21-2006 02:44 PM
Re: any insight into SCP question??
scp remotemachine:/location /source
echo $?
it gives successful of scp command.
--
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2006 02:48 PM
02-21-2006 02:48 PM
Re: any insight into SCP question??
1,14,30,45 * * * * /usr/local/bin/apphire.sh 1>>/tmp/test.log 2>>/tmp/test.err
where,
you can output messages to /tmp/test.log and error to /tmp/test.err file.
Keep track on cron.log also.
--
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2006 03:17 PM
02-21-2006 03:17 PM
Re: any insight into SCP question??
Any updates on this ?
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2006 01:11 AM
02-22-2006 01:11 AM
Re: any insight into SCP question??
I am looking into the key exchange process closer, I've got meetings all morning..
SOURCE:Current SSH on HP side
ssh: SSH Secure Shell 2.3.0 (non-commercial version) on hppa2.0w-hp-hpux11.00
DESTINATION: Current SSH on Linux Side
OpenSSH_4.0p1, OpenSSL 0.9.7f 22 Mar 2005
From Blubricks post I should be able to do the exchange via
1. Create SSH Keys ssh-keygen -t dsa mikeage.net
2. Tell SSH2 who it is (don't ask) echo "idkey id_dsa_1024_a" >> .ssh2/identification mikeage.net
3. Set permissions chmod 600 .ssh2/idkey id_dsa_1024_a.pub .ssh2/identification mikeage.net
4. Copy the public key to the OpenSSH machine scp .ssh/id_dsa_1024_a.pub breeze: mikeage.net
5. Convert the public key, and add it ssh-keygen -i -f id_dsa_1024_a.pub >> .ssh/authorized_keys2 breeze
Not sure, but I think I will have to update SSH on the HP/UX side, kind of leary about doing that as it appears I will have to do some additional patchs..
I will update issue Thursday AM.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2006 01:14 AM
02-22-2006 01:14 AM
Re: any insight into SCP question??
Latest version of Secure shell from HP is, 4.20. You can download and install from,
http://h20293.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=T1471AA
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2006 01:17 AM
02-22-2006 01:17 AM
Re: any insight into SCP question??
I had found it.. I am looking at the prequisites..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2006 02:02 AM
03-09-2006 02:02 AM