Sponsored Content
Full Discussion: [Solved] Shell script help
Top Forums Shell Programming and Scripting [Solved] Shell script help Post 302758005 by Fundix on Friday 18th of January 2013 10:05:48 AM
Old 01-18-2013
A Perl solution (not completely finished, week-end starting Smilie) :
Code:
#!/usr/bin/perl -w
use strict;

my $cur_dir = $ENV{PWD};
my $filename = $cur_dir."/file";
my ($record,@fields,$k,$v,%snap,%env,%name,%prj);

open(FILE,"<$filename") or die"open: $!";

while( defined( $record = <FILE> ) ) {
  chomp $record;
  @fields=split(/ /,$record);

  $snap{$fields[1]}=$fields[2] if($fields[0] =~ m/SNAPSHOT/ );
  $env{$fields[2]}=$fields[4] if($fields[3] =~ m/environment/ );
  $name{$fields[2]}=$fields[4] if($fields[3] =~ m/Name/ );
  $prj{$fields[2]}=$fields[4] if($fields[3] =~ m/project/ );
}

while( my ($k,$v) = each(%snap) ) {
  print "$k,$v,$env{$k},$name{$k},$prj{$k}\n";
}

close(FILE);

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

run shell script under nohup directly [solved]

Hi, i am not able to run the loop in nohup directly. nohup 'for i in $(seq 10); do echo $i;./mscript.sh $i; done' can some one help me how to run this directly in nohup? ---------- Post updated 03-15-12 at 12:20 AM ---------- Previous update was 03-14-12 at 11:59 PM ---------- From... (0 Replies)
Discussion started by: johninweb
0 Replies

2. UNIX for Dummies Questions & Answers

[Solved] Removing control-m characters from shell script

Hi All, I need to remove control m character from a file. Steps which i am doing in shell script are: 1) We are comparing the header of the file to the database table header Here the file header has control-m characters. How do i remove it. Please help. Below are the steps i am using,... (12 Replies)
Discussion started by: abhi_123
12 Replies

3. Solaris

[Solved] Using awk withing a shell script

I am trying to use an awk command within a ksh script but it is not working - I am able to run from command line with no problem. It does not err out - it just does not produce a file with final count. awk "{s+=$0} END {print s}" es.out > es.cntAny help would be greatly appreciated. Thanks (6 Replies)
Discussion started by: bjdamon
6 Replies

4. Shell Programming and Scripting

[Solved] Shell script not working in crontab

Hi Iam running below script in crontab but its not working. #!/bin/sh cd /Scripts /usr/local/bin/expect -f /Scripts/bng_backup.exp /Scripts/data.txt tar -cf bngbackup.tar bngbackup ;gzip bngbackup.tar when iam running manually the output file is generating..but bngbackup.tar.gz file... (5 Replies)
Discussion started by: surender reddy
5 Replies

5. UNIX and Linux Applications

[Solved] How to connect DB2 from UNIX shell script?

Hi all, I have a requirement to connect DB2 database and do some operations and generate a report through shell script. Can anyone please tell me how can i connect DB2 from unix shell script? Thanks in ADV. (2 Replies)
Discussion started by: gani_85
2 Replies

6. Shell Programming and Scripting

[Solved] Get files & delete them by shell script

I want to use my script to get any file then delete it once it transfers to my side , I manage to create below script to generate "list" file which contains all file names in "10.10.1.1" then I made "a.out" file which contains the commands that I want to run it on "10.10.1.1" to get & delete the... (2 Replies)
Discussion started by: arm
2 Replies

7. UNIX for Dummies Questions & Answers

[SOLVED] Mv command doesnt work in shell script

Hi All, i created the below script to move file with xml extension from one directory to another,but the mv command is not working inside the shell script, #!/us/bin/ksh filepath="/apps/extract" filename="*.xml" foldername=2191POB000_$(date +%Y%m%d%H%M%S) mkdir -p "$filepath/$foldername"... (3 Replies)
Discussion started by: Radhas
3 Replies

8. Shell Programming and Scripting

[Solved] Calling PL/SQL Block into Shell Script

Hi, i have one simple PL/SQL Block and i have saved it as .sql file, which i am trying to call from UNIX script. PL/SQL block structure CONNECT DB_NAME/PWD@Database whenever SQLERROR EXIT 1; Declare ..Variables... BEGIN --Code-- exception END; exit; I have save this block as... (3 Replies)
Discussion started by: abhii
3 Replies

9. Shell Programming and Scripting

[Solved] Running a R script with in a shell script

Hi, I do have an R script named KO.R. Basically reads thousands of files, whose name has a pattern that differs at a portion of the file name, List.txt. Row_file1_mile.txt Row_file2_mile.txt Row_file3_mile.txt ... ... Row_file1000_mile.txt Below is a portion of my Rscript that reads... (4 Replies)
Discussion started by: Kanja
4 Replies

10. Shell Programming and Scripting

[Solved] Help with shell Script ,wait for some files for some time??

Hi All, I have the requirement that ,i have to write a shell script that job has to wait for a 7 touch files created by another application for 4 hours, if i get all 7 touch files ,i have to send a mail that i jobs are completed, if if it is waiting for more than 4 hours i have to send a mail... (2 Replies)
Discussion started by: Pradeep Shetty
2 Replies
AJ-SNAPSHOT(1)							   User Manuals 						    AJ-SNAPSHOT(1)

NAME
aj-snapshot SYNOPSIS
aj-snapshot [ -adfjqrx ] [ -p polling_interval ] [ -i client_name ]... [ FILE ] DESCRIPTION
Aj-snapshot is a small program that can be used to make snapshots of the connections made between JACK and/or ALSA clients. Because JACK can provide both audio and MIDI support to programs, aj-snapshot can store both types of connections for JACK. ALSA, on the other hand, only provides routing facilities for MIDI clients. If you call aj-snapshot without any options, aj-snapshot will store all current ALSA and JACK connections to FILE. The file will be an XML file, and you can use a text-editor if you want to edit it manually. OPTIONS
-a or --alsa Only store or restore ALSA midi connections. Also works in daemon mode. -d or --daemon Run aj-snapshot in daemon mode. Aj-snapshot will first try to restore the connections from the specified snapshot file. After this, it will wait for new ports to be registered with ALSA or JACK. Every second by default, aj-snapshot will check if new ports were registered in ALSA or JACK. When this is the case, it will try to restore the connections from your snapshot file. If you start aj- snapshot in daemon mode, you don't need to specify the -r,--restore flag as it is implied anyway. If you send the HUP signal to the daemon, the daemon will reload the snapshot file. This gives you the possibility to trigger a con- nections restore. For an example on how to do this, see the EXAMPLES section below. When you combine the daemon mode with the -x,--remove option, sending the HUP signal to the daemon will clear all connections before restoring. When the JACK server is stopped (or crashes) while aj-snapshot runs in daemon mode, aj-snapshot will try to keep running. When the JACK server is started again later, aj-snapshot will reattach automatically and restore your connections when needed. -f or --force When you try to save a snapshot over an existing file, aj-snapshot will ask you if you want to overwrite that file. With this option, you can force aj-snapshot to overwrite that file. -j or --jack Only store or restore JACK audio and midi connections. Also works in daemon mode. -p interval Whenever a program registers a port with ALSA or JACK, aj-snapshot will see if there are connections in the snapshot file that should be restored. By default, aj-snapshot will check (poll) if there are new ports every second (1000 milliseconds). With this option you can choose how often aj-snapshot should check for new ports. The value of interval should be specified in milliseconds. -q or --quiet Don't print any information about the connections that are stored or restored. -r or --restore When you specify the -r flag, aj-snapshot will try to restore all ALSA and JACK connections from FILE. (without it, aj-snapshot will try to store connections to FILE). You can combine this option with the -a or -j options, if you want to restore ALSA or JACK con- nections only. -x or --remove The -x option can be used when restoring connections, or when running in daemon mode. With this option, aj-snapshot will remove all existing connections before restoring the snapshot file. When you combine it with the -a or -j option, only the connections for the specific subsystem (ALSA or JACK) will be removed. Without the -x option, aj-snapshot will try to restore connections on top of the connections that are already active. There is one more way in which you can use the -x option. If you call aj-snapshot without the FILE argument, you can use the -x option to remove all existing ALSA and JACK connections (without doing anything else). As before you can combine it with the -a or -j options. -i client_name You can use this option to name a client that should be ignored by aj-snapshot. You should write the exact name of the client after the -i option. If that name contains spaces, or other characters that have special meaning to the shell, you should put the name between single (safest) or double quotes. To know the exact name of a client, you could save a snapshot and look up the name in the snapshot file. If you want to ignore multiple clients, you have to repeat the -i option with different client names (the maximum is 50 clients). -h or --help Print a short help message EXAMPLES
aj-snapshot test.snap Stores a snapshot of all current ALSA and JACK connections to a file called "test.snap". If that file already exists, aj-snapshot will ask you if you want to overwrite that file. aj-snapshot -r test.snap Restores all ALSA and JACK connections from the file "test.snap". This will leave any other active connections intact. aj-snapshot -xr test.snap Restore all ALSA and JACK connections from the file "test.snap", but remove all existing connections first. aj-snapshot -a test.snap Store all current ALSA connections to "test.snap". aj-snapshot -rj test.snap Restore all JACK connections from "test.snap". This means that ALSA connections that might be stored in the file won't be restored. aj-snapshot -qfj test.snap Store all current JACK connections to "test.snap". Don't print any info on standard out (be quiet), and forcibly overwrite "test.snap" if it already exists. aj-snapshot -ax Remove all ALSA connections aj-snapshot -d test.snap & Run aj-snapshot in daemon mode and make it a background process (&). Whenever a new ALSA or JACK client registers a port, connec- tions from test.snap will be restored. aj-snapshot -djx test.snap & Run aj-snapshot in daemon mode for the JACK connections in "test.snap". Remove all existing JACK connections whenever the connec- tions from test.snap are restored. 1) aj-snapshot -d test.snap & 2) aj-snapshot -f test.snap 3) kill -HUP $(pidof aj-snapshot) 1) First start up aj-snapshot in daemon mode with the file "test.snap". 2) After some connection changes, a second instance of aj-snapshot (which is not run in daemon mode) overwrites that file with the new connections state. 3) Send the HANGUP signal to the daemon to make it reload the file with the new connections state (see 'man kill', and 'man pidof'). AUTHOR
Written by Lieven Moors and Jari Suominen REPORTING BUGS
To report aj-snapshot bugs, or if you have feature requests: <http://sourceforge.net/projects/aj-snapshot/> Aj-snapshot home page: <http://aj-snapshot.sourceforge.net/> Clone the git repository: git clone <git://gitorious.org/aj-snapshot/aj-snapshot.git> COPYRIGHT
Copyright (C) 2009-2012 Lieven Moors and Jari Suominen. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Linux NOVEMBER 2011 AJ-SNAPSHOT(1)
All times are GMT -4. The time now is 01:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy