Operating System - HP-UX
1834798 Members
2814 Online
110070 Solutions
New Discussion

Re: Perform a copy with very limited command availability

 
SOLVED
Go to solution
Bryan Rooney
Frequent Advisor

Perform a copy with very limited command availability

I have a system (11.23 Sept 2006, Itanium)that I'm about to recovery via ignite, but want to attempt to resolve the issue by copying a file using the available commands. The cause of the problem is that someone has moved the /usr/lib/hpux32/dld.so library instead of copying it, so now there is no /usr/lib/hpux32/dld.so library.
Bascially, I'm looking to see if anyone with crazy shell skills can copy a file with only the following commands available:
ls
pwd
touch
cd
echo
<
>
|

All other commands (cp, mv, dd, tar, cat, etc, etc) are trying to access the missing 32bit library and core dump. Any way to get the commands to use the 64 bit version of the library (assuming they even can)? The 64bit version of the library was left intact.

I tried the following, but it translated the binary content into ascii or the like:
# echo $( file2

If not possible I'll recover via Ignite.
19 REPLIES 19
Geoff Wild
Honored Contributor

Re: Perform a copy with very limited command availability

I think ignite is your friend - either that or go to a HP-UX recovery shel - there you will have access t the cp command.

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Pete Randall
Outstanding Contributor

Re: Perform a copy with very limited command availability

Try:

file2 < file1


Pete

Pete
Pete Randall
Outstanding Contributor

Re: Perform a copy with very limited command availability

Disregard. Probably should have tried it myself before posting.

;^(


Pete

Pete
Bryan Rooney
Frequent Advisor

Re: Perform a copy with very limited command availability

I'm working from the recovery shell(hpux -is). Ther is no cp that I can find unless I mount /usr, ...then it starts looking for the lib in /usr and cores. The file that needs to be renamed is on /usr so it needs to be mounted.
Ignite should work just fine, but I've heard that there are ways to do copies in these situations, but have never seen it done. Would be much easier to cp the file back into place then go through the ignite process, though I have a feeling that is where I'll be going.
Pete Randall
Outstanding Contributor
Solution

Re: Perform a copy with very limited command availability

Running "hpux -is" gets you to single user mode, which is not the recovery shell. I believe you have to boot into the recovery shell from the install media.


Pete

Pete
Geoff Wild
Honored Contributor

Re: Perform a copy with very limited command availability

Yes, sorry - I meant to say boot from Install Media as Pete said...not hpux -is

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
TwoProc
Honored Contributor

Re: Perform a copy with very limited command availability

What about "dd", I've always thought that command was fully bound.
If so,

dd if=/wherever/dld.so of=/destination/dld.so


We are the people our parents warned us about --Jimmy Buffett
TwoProc
Honored Contributor

Re: Perform a copy with very limited command availability

Can you still ssh over to another machine?
I doubt it, but if this is the case... then scp might work from another machine...

From remote machine:

scp -p yourhost:/whereever/dld.so yourhost:/usr/lib/hpux32/dld.so





We are the people our parents warned us about --Jimmy Buffett
Bryan Rooney
Frequent Advisor

Re: Perform a copy with very limited command availability

The dd command is not available, I should have put that one in the first note. I've seen ome crazy things done at the shell prompt. I'm not convinced that there isn't some way........
I do like the boot of install media idea, but I can sit at my desk and do the Ignite and call it good. No trip to the data center in the Ignite solution.
Bryan Rooney
Frequent Advisor

Re: Perform a copy with very limited command availability

The machine will boot, but not let anyone on. It's gets init to rapidly messages on the console due to programs trying to start and no dld.so library being present. So any higher level command, network commands included (ssh, scp, telnet, ftp, tftp, etc), are not available.

If the solution comes from the shell, it will have to come from the low level commands somehow.
James R. Ferguson
Acclaimed Contributor

Re: Perform a copy with very limited command availability

Hi:

How about :

# /sbin/cat filein > fileout

Regards!

...JRF...
TwoProc
Honored Contributor

Re: Perform a copy with very limited command availability

The closest I've come is:
while read -r c
do
echo $c
done < testfile > testout

However, the danged thing is parsing, and doesn't like binaries...
We are the people our parents warned us about --Jimmy Buffett
larsoncu
Advisor

Re: Perform a copy with very limited command availability

doesn't the /sbin directory have many utilites that aren't dependent on shared libraries. ie when booting, single user mode, etc. /usr isn't mounted.

make sure /sbin is in your PATH and then make sure it is before /usr/bin
Juan M Leon
Trusted Contributor

Re: Perform a copy with very limited command availability

what about ftp to itself then mv. I am not sure if ftp will look for the missing library.
Patrick Wallek
Honored Contributor

Re: Perform a copy with very limited command availability

Yes, the binaries in /sbin are statically linked, so you don't need share libraries.

However, there is no /sbin/cp command. There is however a /sbin/mv command.

So, if you use /sbin/mv to move the /usr/lib/hpux32/dld.so back to its appropriate spot, then all should be OK again.

Note, that you don't have to mess with your PATH environment variable if you just give the full path to the command.
Bryan Rooney
Frequent Advisor

Re: Perform a copy with very limited command availability

We have a winner!!!!

James R. Ferguson was the first to suggest the pathing issue with /sbin.
I now feel like a complete heel for not seeing this myself in the first place!
I was able to use the cat command as suggested. Both larsoncu and Patrick Wallek realized the same solution. The path assigned by hpux -is and hpux -lm has /sbin last. I was thinking there was some real crazy shell magic, but I'll take any simple soultion!

Many thanks for everyones help with this.
James R. Ferguson
Acclaimed Contributor

Re: Perform a copy with very limited command availability

Hi Bryan:

>James R. Ferguson was the first to suggest the pathing issue with /sbin

So, do I get a point? :-))

Regards!

...JRF...
Bryan Rooney
Frequent Advisor

Re: Perform a copy with very limited command availability

Yup, just noticed that myself. Points have been assigned.
Bryan Rooney
Frequent Advisor

Re: Perform a copy with very limited command availability

The ${PATH} env var has /sbin last when running hpux -is or hpux -lm, so when /usr was mounted the commands were trying to go through the lib in /usr that was missing. Using full pathing to commands available in /sbin resolved the situation.