LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-24-2013, 11:28 AM   #16
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,961

Rep: Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693

Quote:
Originally Posted by prashanth1414 View Post
run command:./script.name
error: connect to host servername port 22: Connection refused
lost connection
scriptname.sh failed.

This is the error which i get when i copy my script from linux box to the Stellant server which i mentioned in the script.Im using scp to perform this task.
...and you STILL aren't clear. Do you mean the SCRIPT fails, or that you can't COPY IT??? The way you're wording things it could be either. And now you're saying that you're copying scripts FROM Linux, TO another server...which is the EXACT OPPOSITE of what you originally posted. If it's telling you that it can't connect to port 22 (SSH), then you obviously have some sort of issue...either the hostname is wrong, IP address is wrong, firewall is blocking you, etc.

AGAIN, there is no magic formula. If the script you posted is failing, then address it line by line. Run the commands, verify what's there. Doesn't get simpler (or harder) than that. Again, the administrator at your company should be able to help you with things like this...have you asked them?
 
Old 06-24-2013, 04:16 PM   #17
dayid
Member
 
Registered: Apr 2012
Location: Austin, TX
Posts: 44

Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
Well, you're not specifying the path correctly, no matter WHAT *nix you're using. You need the leading "/", such as "scp -p /my/dir user@host:/dest/dir", so I'm not surprised it's failing.
That's incorrect; consider:
Code:
localhost$ cd
localhost$ pwd
/home/dayid/
localhost$ scp mydir/myfile remoteuser@remotehost:~/mydir/
localhost$ ssh remoteuser@remotehost
remotehost$ pwd
remotehost$ /home/remoteuser
remotehost$ ls mydir/
myfile
 
Old 06-24-2013, 05:09 PM   #18
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,961

Rep: Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693
Quote:
Originally Posted by dayid View Post
That's incorrect; consider:
Code:
localhost$ cd
localhost$ pwd
/home/dayid/
localhost$ scp mydir/myfile remoteuser@remotehost:~/mydir/
localhost$ ssh remoteuser@remotehost
remotehost$ pwd
remotehost$ /home/remoteuser
remotehost$ ls mydir/
myfile
You're putting the "~" qualifier in for the remote path, and where is the "mydir" on the source host? If it's not a subdirectory of where you currently are, you'll have problems. Qualifying the full path (especially for automation/scripting tasks), should always be done, in my opinion.

It *MIGHT* work without the leading "/"...but only if things are just right.
 
Old 06-24-2013, 05:19 PM   #19
prashanth1414
LQ Newbie
 
Registered: Jun 2013
Posts: 10
Blog Entries: 1

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
You're putting the "~" qualifier in for the remote path, and where is the "mydir" on the source host? If it's not a subdirectory of where you currently are, you'll have problems. Qualifying the full path (especially for automation/scripting tasks), should always be done, in my opinion.

It *MIGHT* work without the leading "/"...but only if things are just right.
ok..let me explain you..
STELLANT_DIR=/this/is/my/source/dir
STELLANT_PARSER=/this/is/dest/dir/filenmae
STELLANT_SERVER=servername

--now i am copying the xxx.dat generated file in source dir to the specified dest dir
scp -p $STELLANT_DIR/xxx.dat username@$STELLANT_SERVER:$STELLANT_PARSER

when i run this script in linux,using command ./script.ksh

error:
ssh: connect to host SERVERNAME port 22: Connection refused
lost connection
script.sh failed..

Thanks.
 
Old 06-24-2013, 06:07 PM   #20
dayid
Member
 
Registered: Apr 2012
Location: Austin, TX
Posts: 44

Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
You're putting the "~" qualifier in for the remote path, and where is the "mydir" on the source host? If it's not a subdirectory of where you currently are, you'll have problems.
As shown by the "pwd", it's there.

I agree it *should* be done, but that's not what you said. To be clear: full paths *should* be used; however, your statement of:
Quote:
Originally Posted by TB0ne
no matter WHAT *nix you're using. You need the leading "/",
is misleading. That's all I was correcting.
 
Old 06-24-2013, 08:31 PM   #21
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
Just run the scp cmd manually until you get it working.
In any case, the error means what it says
Code:
 ssh: connect to host SERVERNAME port 22: Connection refused
One or more of
1. sshd not listening on port 22
2. firewall blocking
3. invalid acct details

In all cases, talk to your local sysadmin.
 
Old 06-25-2013, 10:23 AM   #22
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,961

Rep: Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693
Quote:
Originally Posted by dayid View Post
As shown by the "pwd", it's there.

I agree it *should* be done, but that's not what you said. To be clear: full paths *should* be used; however, your statement of is misleading. That's all I was correcting.
That's quite true, but I disagree somewhat with it being misleading; wrong would be better.
 
Old 06-25-2013, 02:35 PM   #23
prashanth1414
LQ Newbie
 
Registered: Jun 2013
Posts: 10
Blog Entries: 1

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
That's quite true, but I disagree somewhat with it being misleading; wrong would be better.
what is misleading in the script or command..
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Issue faced in migration of ksh scripts from SunOS to Linux senthilkumar.cud Linux - General 2 08-24-2012 09:29 AM
Aix - Linux Scripts Migration Issues kumarancs Linux - Newbie 4 09-07-2011 12:50 PM
Solaris to Linux Migration? soupbone38 Solaris / OpenSolaris 2 02-28-2009 04:51 AM
Porting ksh script from Solaris to Linux Gives unmatched if error markatharvestinfotec Programming 4 08-28-2008 02:51 PM


All times are GMT -5. The time now is 08:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration