Not able to get value in 3rd variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Not able to get value in 3rd variable
# 1  
Old 08-30-2012
Not able to get value in 3rd variable

Perl Legends,

I am trying to debug below perl script. Till "h1" and "h2" the value in variable is initialized. but as soon as it execute the command for 3rd variable "h3" it terminates.

Code:
$h1=`/usr/bin/head -1 /tmp/a/$ARGV[3]`;
print TEST "after h1\n";
print TEST "$h1\n";

$h2=`/usr/bin/head -1 /tmp/b/$ARGV[3]`;
print TEST "after h2\n";
print TEST "$h2\n";

$h3=`/usr/bin/head -1 /tmp/c/$ARGV[3]`;
print TEST "after h3\n";
print TEST "$h3\n";


@head = ( $h1, $h2, $h3 );

print TEST "after head1\n";
                        $h = 0;
                        foreach $header (@head) {
                                if ($header =~ /Host/) { $h++; }
                        }
print TEST "after head2\n";




OUTPUT

after h1
# Host: a Start time: 08/30/12 01:30:56

after h2
# Host: b Start time: 08/30/12 01:30:56

--- And it terminates after h2

Pls help
# 2  
Old 08-30-2012
substitute the value of ARGV[3] in this:

Code:
/usr/bin/head -1 /tmp/c/(..actual filename here..)

Does the word "Host" appear in the output? The file may not be formatted as you expect or may be empty. Your perl example is logically ok, but did not produce output you show, so I assume you edited your code for brevity.
# 3  
Old 08-30-2012
Quote:
Originally Posted by jim mcnamara
substitute the value of ARGV[3] in this:

Code:
/usr/bin/head -1 /tmp/c/(..actual filename here..)

Does the word "Host" appear in the output? The file may not be formatted as you expect or may be empty. Your perl example is logically ok, but did not produce output you show, so I assume you edited your code for brevity.
Sorry forgot to mention,
Actually, it same file in 3 different directories (a,b,c)
When i am running it manually, it displays the first line, but not through script,
and this script is being called remotely from other host using "ssh -xCf <hostname 1..2..3> <filename>
and the <filename> passed on before making ssh connection is the argument ARGV[3]

So any idea, when script is called remotely, then why it stuck after "h2"
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

3rd field in /etc/shadow

Searched and searched, but could not find a official answer. In Solaris, on a new server build, all the system accounts look like this: # cat /etc/shadow root:#########:6445:::::: daemon:NP:6445:::::: bin:NP:6445:::::: sys:NP:6445:::::: adm:NP:6445:::::: lp:NP:6445::::::... (6 Replies)
Discussion started by: flyddw
6 Replies

2. Shell Programming and Scripting

Compare 3rd column in 2 files

I have the following 2 files. File 1 08FB,000192602673,10000000c9a6b240 0121,000192602673,20000025b550101f 0121,000192602673,20000025b550100f 08FA,000192602673,10000000c9a6b240 File 2 18F2,000195702363,10000000c9a6b240 18F3,000195702363,10000000c9a6b240... (2 Replies)
Discussion started by: kieranfoley
2 Replies

3. AIX

PowerHA with 3rd node for communication

Looking to find PowerHA with 3rd node used for communication (voting node) only. Does anyone use such configuration with IBM products? (2 Replies)
Discussion started by: gogogo
2 Replies

4. Shell Programming and Scripting

how to get 3rd week of every friday?

Legends, how do i get 3rd week of friday in every month and execute a particular script say /tmp/abc.sh ??? i think after "cal" we can traverse through using some for loop.:wall: pls help me. Dosanjh (8 Replies)
Discussion started by: sdosanjh
8 Replies

5. Shell Programming and Scripting

Decrement one from 3rd Column

Hi, I need a script that will subtract 1 from the third column of the line beginning with %, leaving all other values the same. So 158 should be 157, 308 should be 307, 458 should be 457. Before: # 30109 xyz abc Data % 30109 158 5 8 2 000023f 01f4145 # 30109 ... (3 Replies)
Discussion started by: morrbie
3 Replies

6. Programming

libnotify (g_signal_connect() 3rd argument help) c++

Hello, this is my code: #include <glib.h> #include <unistd.h> #include <libnotify/notify.h> void push_notification (gchar* title, gchar* body, gchar* icon) { NotifyNotification* notification; gboolean success; ... (0 Replies)
Discussion started by: hakermania
0 Replies

7. Shell Programming and Scripting

Need to get the 3rd column

Hi Trying to do get the 3rd column out. Any help would be much appreciated Hardware OS Client --------------- --------------- -------------- PC WindowsNET test1 PC WindowsNET test2 PC WindowsNET test3... (6 Replies)
Discussion started by: bombcan1
6 Replies

8. Shell Programming and Scripting

will only show every 3rd line

Hi, how will i show every 3rd line of the file. Ex. line 1 line 2 line 3 line 4 line 5 line 6 line 7 Output: line 2 line 5 line 6 tyhanks ---------- Post updated at 03:39 AM ---------- Previous update was at 03:37 AM ---------- (2 Replies)
Discussion started by: kenshinhimura
2 Replies

9. Shell Programming and Scripting

How to define a variable with variable definition is stored in a variable?

Hi all, I have a variable say var1 (output from somewhere, which I can't change)which store something like this: echo $var1 name=fred age=25 address="123 abc" password=pass1234 how can I make the variable $name, $age, $address and $password contain the info? I mean do this in a... (1 Reply)
Discussion started by: freddy1228
1 Replies

10. Shell Programming and Scripting

how to change every 3rd character

hey champs, i have a files, whose contents are as follows, abcdefghijk lmnopqrstuv .............. .............. i want to replace every other 3rd character to some specified character. let here in this file i want to replace each 3rd character to z. abzdezghzjk lmzopzrszuv... (2 Replies)
Discussion started by: manas_ranjan
2 Replies
Login or Register to Ask a Question