Script failing to run successfully on remote node


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script failing to run successfully on remote node
# 1  
Old 09-23-2011
Script failing to run successfully on remote node

Hi guys,
I have a scenario where i want to run a script from Node A. It ssh's into Node B and runs some awk commands there plus deposiriting the output on Node B.
Challenge is that the awk commands run properly when executed locally on Node B but fail when within the script on Node B. I do not get the desired output in this case.

Code:
 
#!/bin/ksh 
(/export/home/doodie/node_call NODE1) 2>&1
(/export/home/doodie/node_call NODE2) 2>&1
(/export/home/doodie/node_call NODE3) 2>&1
# cat node_call 
#!/bin/ksh 
# GET SOME DATA 
case $1 
in 
NODE1) 
name=SD1 
node=sd1b 
;; 
NODE2) 
name=SD2 
node=sd2b 
;; 
NODE3) 
name=SD3 
node=sd3b 
;; 
 
*) 
;; 
esac 
DT=$(date '+%Y%m%d') 
ssh -i /SSH_KEYS/keys user@$node <<EF 
cd /var/direct/ 
awk 'BEGIN {print "ID_NAME,ID,BAL,STATUS,EXP1,EXP2"} {FS=OFS=",";print $1,$18,$21,$22,$23,$24}' "$name".file1.csv > "$name"_data1_"$DT" 
 
EF


The raw files are


Code:
 
 $ cat file1.csv
 
213039892,3273039892,0,0,,0,0,1,0,0,0,0,0,0,0,0,0,5,5,,0.000000,1,2011-12-13,2011-12-13,,2012-03-12,0,0,2012-03-12,0,0,,0,0,0,0,0,0,0,0,0,0,0,2011-09-14 
213532518,3273532518,0,0,,0,1,1,0,0,0,1,0,0,0,0,0,5,5,,5.675000,1,2012-09-14,2012-09-14,,2013-06-11,0,0,2013-03-13,0,0,,0,0,0,0,0,0,0,0,0,0,0,2011-07-27 
212082217,3282082217,0,0,,0,1,1,0,0,0,1,0,0,0,0,0,5,5,,11.775000,1,2012-07-05,2012-07-05,,2013-04-01,0,0,2013-01-01,0,0,,0,0,0,0,0,0,0,0,0,0,0,2011-07-11 
213608503,3273608503,0,1,,0,1,1,0,0,0,1,0,0,0,0,0,5,5,,2.575000,1,2012-09-08,2012-09-08,,2013-06-05,0,0,2013-03-07,0,0,,0,0,0,0,0,0,0,0,0,0,0,2011-07-21 
217427440,3277427440,0,0,,0,0,1,0,0,0,0,0,1,0,1,0,5,5,,0.000000,0,,,,,0,0,,0,0,,0,0,0,0,0,0,0,0,0,0,0, 
215677789,3285677789,0,0,,1,1,1,0,0,0,1,0,0,0,0,0,5,5,,477.550000,1,2012-09-16,2012-09-16,,2013-06-13,0,0,2013-03-15,0,0,,0,0,0,0,0,0,0,0,0,0,0,2010-01-24
215970109,3285970109,0,0,,0,1,1,0,0,0,0,0,0,0,0,0,31,31,,6.810000,1,2011-05-30,2011-05-30,,2012-02-24,0,0,2011-11-26,0,0,,0,0,0,0,0,0,0,0,0,0,0,2010-02-21
219096998,3279096998,0,0,,0,0,1,0,0,0,0,0,1,0,1,0,5,5,,0.000000,0,,,,,0,0,,0,0,,0,0,0,0,0,0,0,0,0,0,0, 
219856498,3279856498,0,0,,0,0,1,0,0,0,0,0,1,0,1,0,5,5,,0.000000,0,,,,,0,0,,0,0,,0,0,0,0,0,0,0,0,0,0,0, 
213867504,3273867504,0,0,,1,1,1,0,0,0,0,0,0,0,0,0,5,5,,811.625000,1,2012-09-16,2012-09-16,,2013-06-13,0,0,2013-03-15,0,0,,0,0,0,0,0,0,0,0,0,0,0,2011-02-16


Expected output


Code:
 
$ cat SD1_data1_20110923
 
ID_NAME,ID,BAL,STATUS,EXP1,EXP2 
213039892,5,0.000000,1,2011-12-13,2011-12-13 
213532518,5,5.675000,1,2012-09-14,2012-09-14 
212082217,5,11.775000,1,2012-07-05,2012-07-05 
213608503,5,2.575000,1,2012-09-08,2012-09-08 
217427440,5,0.000000,0,, 
215677789,5,477.550000,1,2012-09-16,2012-09-16 
215970109,31,6.810000,1,2011-05-30,2011-05-30 
219096998,5,0.000000,0,, 
219856498,5,0.000000,0,,


Output now

Code:
 
ID_NAME,ID,BAL,STATUS,EXP1,EXP2 
,,1,2,3,4
,,1,2,3,4
,,1,2,3,4
,,1,2,3,4
,,1,2,3,4
,,1,2,3,4
,,1,2,3,4

---
Mod addendum: nice attempt to use code tags... Look at:
Moderator's Comments:
Mod Comment Please use code tags

Last edited by jerkesler; 09-29-2011 at 08:33 AM.. Reason: corrected code tags...
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Except script to run a local shell script on remote server using root access

local script: cat > first.sh cd /tmp echo $PWD echo `whoami` cd /tmp/123 tar -cvf 789.tar 456 sleep 10 except script: cat > first #!/usr/bin/expect set ip 10.5.15.20 set user "xyz123" set password "123456" set script first.sh spawn sh -c "ssh $user@$ip bash < $script" (1 Reply)
Discussion started by: Aditya Avanth
1 Replies

2. Shell Programming and Scripting

Except script fails to check file exists or not in remote node

Dear members, The following expect script connects to remote node and check for the file "authorized_keys" in directory /root/.ssh in remote node. However the result is always found even if the file exist or doesn't exist. expect { "$fname" { send_user "found\n" } Any idea what is... (4 Replies)
Discussion started by: Sudhakar333
4 Replies

3. Shell Programming and Scripting

Run script on remote host

Hi friends, I have two servers. Server A and B. I want to run one script on server A by logging in to server B. Can anyone provide me code for this.? I tried it by using following ssh username@serverA ./script Then it prompt me the password. I give correct password of the server A. but it... (7 Replies)
Discussion started by: Nakul_sh
7 Replies

4. UNIX for Advanced & Expert Users

Unable to run the script on remote machine Using Expect script

Not able to execute the file in remote host using except utility I am automating the SFTP keys setp process: So i created the expect script for controlling the output of shell below is my main code: Code: #!/usr/bin/expect set fd set password close $fd set df set app close $df... (1 Reply)
Discussion started by: Manoj Bajpai
1 Replies

5. Solaris

Has anyone successfully run the new series UPS Powerware and Sol2.6?

Нi fellows. There is a small question there. The old UPS Powerware died. On Sol 2.6 was installed the utility LanSafe 3. Befriend someone already Powerware UPS new series such as 5110, 5115, 5125 etc. with Sol2.6? There is LanSafe 603 (only for SPARC 2.7, 8, 9,10) on the company web site.... (0 Replies)
Discussion started by: wolfgang
0 Replies

6. Shell Programming and Scripting

run remote perl script

Hello i want create perl script to connect remotely to another machine and run perl script please note that the remote script check for different variables remotely and not located on local machine also i want to know how to send interactive variables i am trying to make script to... (2 Replies)
Discussion started by: mogabr
2 Replies

7. UNIX for Dummies Questions & Answers

Run a script on remote host

Hi, I wish to run a script located on a remote host machineB from machineA. I am using ssh and running the below on machineA. However, the ssh does not seem to work and freezes at ssh -l wlsadmin machineB -v Sun_SSH_1.1.2, SSH protocols 1.5/2.0, OpenSSL 0x0090704f debug1: Reading... (9 Replies)
Discussion started by: shifahim
9 Replies

8. Programming

Expect script to run a Shell script on remote server

Hi All, I am using a expect script to run a shell script on remote server, the code is as follows. But the problem is that it executes only first command, and hangs it doesn't run the next commands. spawn ssh $uid@$host expect "password:" send "$password\r" expect "*\r" send... (2 Replies)
Discussion started by: yashwanthsn
2 Replies

9. Shell Programming and Scripting

Run a shell script from one host which connext to remote host and run the commands

I want to write a script which would run from one host say A and connect to other remote host B and then run rest of commands in that host. I tried connecting from A host to B with SSH but after connecting to host B it just getting me inside Host B command prompt. Rest of the script is not running... (6 Replies)
Discussion started by: SN2009
6 Replies
Login or Register to Ask a Question