Programming :: Find Out If X11 Is Running From Within Perl OR Bash Script?

Mar 17, 2010

I am writing a script based image manipulator but i need to know if X is running so i can tell if i use CACAVIEW to imagemagick DISPLAY command.

View 14 Replies


ADVERTISEMENT

Programming :: Find And Replace A String In A File Using Perl Command From Bash Script?

Feb 14, 2011

I wanted to find and replace a string from a perl file. I have written a script in bash which runs the following command.

perl -pi -e "s/$findstring/$replacestring/" testfile
where as $findstring = print F_WC_TMP"$line
";
and $replaceString = $line = join ' ', split ' ', $line; print F_WC_TMP"$line
";

But when I am running the above command, i think it is replacing the $findstring with the above mentioned string and hence it contains a $line, it is looking for the variable $line and not finding the exact string. I am confused about how to search for a string that contains $ in it and replace it with another $string.

View 5 Replies View Related

Fedora :: Running Bash And Perl Scripts On Desktop

Nov 8, 2010

I wanted to run bash and perl scripts which requires SU privileges by clicking on desktop
Terminal window opens and closes fast without knowing what happened.

scripts work on terminal window by telling
sudo perl file.pl
sudo bash file.sh

Perl has this header
#!/usr/bin/env perl
or
#!usr/bin/perl -w

Bash has header
#!/bin/bash

How can I run them with desktop shortcuts with SU privilege so, the terminal will not close after execution? Should not the scripts work without telling perl or bash, since they have the header?

View 4 Replies View Related

Ubuntu :: Running Bash Perl Scripts On Desktop Click?

Nov 8, 2010

I wanted to run bash and perl scripts which requires SU privileges by clicking on dektop Terminal window opens and closes fast without knowing what happened.

scripts work on terminal window by telling

sudo perl file.pl
sudo bash file.sh
Perl has this header
#!/usr/bin/env perl

[Code]....

How can I run them with desktop shortcuts with SU privilege so, the terminal will not close after execution?

should not the scripts work without telling perl or bash,

View 1 Replies View Related

Programming :: Bash And Perl - Script Adjustment

May 24, 2010

I wrote this script for bash & perl. If you run it in bash it should work. It changes title - (uuid) kernel - initrd ... to title - uuid UUID=the_uuid... kernel - initrd .... When I wrote it I replaced end of lines by . It's the second $block definition. But now I need to repair it, because I will work with the 1st $block definition. That is not to exclude end of lines, but leave it be untouched. Now when you escape the second $block definition, the code does not work. What I have to do to repair it working with multiline input data?

Code:
block="title Sata Mandriva
kernel (UUID=eab515e9-bc3e-4024-9f01-55fddaa0fb1c)/boot/vmlinuz BOOT_IMAGE=linux root=UUID=eab515e9-bc3e-4024-9f01-55fddaa0fb1c resume=UUID=e12487ff-6d6f-44c4-9e03-33f545b3b798 splash=silent vga=788
initrd (UUID=eab515e9-bc3e-4024-9f01-55fddaa0fb1c)/boot/initrd.img"; .....

View 10 Replies View Related

Programming :: Easier Way To Color Text In Perl Like BASH?

Apr 8, 2010

I've been trying to figure out a way to more easily color text in Perl like I do on Bash on a Linux box. In bash, what I'll do is set color variables up to equal the escape sequence, then echo out with escape seqeunces to print it exactly how I want it. Typically I'll want a character or a word in a different color, not the whole line. For example

echo -n -e "My face is turning ${RED}red${UNCOLOR} like a lobster." In Perl with the term::ANSIColor module, it seems to just do a line. Am I being dense? Is there a way that I can do it like I do it in BASH that's fairly easy to read after the fact?

View 11 Replies View Related

Programming :: Looking For A Bash / Perl Script To Read New RSS Feeds (XML Url)?

Feb 13, 2011

I would like to find something portable that work on all machines. I have hmtl2text installed, and perl and sh.

Anyone would know if someone already made such thing to read new through the console ?

View 1 Replies View Related

Programming :: Manipulating A Date In A Perl Bash Script?

Mar 11, 2010

I've recently inherited a bunch of files at a new job and am trying to figure out some of the problems that have constantly popped up. The one i'm getting a huge headache with results from a bash script that is supposed to change a date format from a client populated txt field to one we want defined a certain way. Everything in the script works fine, except that one function. Below is the line i'm trying to manipulate, with date examples.

sed -e 's/.0000 EA/ EA/' -e 's/ 01012010 / 01-JAN-2010 /' -e 's/ 12312011 / 31-DEC-2011 /'

The one caveat is that the first date is non-static and changes daily. It is, however, always the current date. If it helps, the second date will always be a year away from the first date.My idea was to pull the current date via perl's DATE function, but...how to do it, and calculate a year away without throwing the rest of the bash script off? Any help would be appreciated. I'm sure it's a simple solution but i know absolutely nothing about these scripts and how they were written.

View 10 Replies View Related

Programming :: Scripting, Perl Or Bash; Run A Background Process, Get Pid?

Apr 1, 2010

pretty simple. how would you background a process from a script and get its process id at the same time?

View 6 Replies View Related

Programming :: Sed Bash Command - Not Print Backslash In Perl

Jul 11, 2010

This pretend to be a script for rename a lot of files automatically. So I put the list of files in an array named @lista. But, as you can see, at the end of the command I use a sed filter to print out a backslash for those files that have spaces in their names, so the path for those files could be rightly interpreted.

But there's no way I could print a backslash. It works well when I use the Perl's sed substitution s///, but I need every path in the array to be fixed.

I'd like to add that the bash command works perfectly well alone. I mean outside the Perl script.

This is de command line with the sed filter:

Code:

And this is what it brings:

Code:

View 12 Replies View Related

Programming :: Bash / Perl : Copying Data From A CD/DVD To Hard Drive?

May 4, 2010

Seeking a decent Perl or Bash script or hack used to copy data from a CD/DVD to local or even remote hard drive/storage.

View 7 Replies View Related

Programming :: Unable To Find The Perl

Mar 9, 2011

Just installed Fedora 14. I wanted to try "Hello World" with perl. But where is it?

Code: [user]@user bin]$ ls

View 1 Replies View Related

Programming :: Perl Can't Find The Readonly.pm

May 18, 2010

I am following a gtk2-perl tutorial, so I wrote the test program, installed gtk2-perl, and got this error:

Code:

Can't locate readonly.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.10.1 /usr/share/perl5/site_perl/5.10.1 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5/core_perl /usr/share/perl5/core_perl /usr/lib/perl5/current /usr/lib/perl5/site_perl/current .) at ./test.pl line 7. BEGIN failed--compilation aborted at ./test.pl line 7.

I googled readonly.pm, and figured out it's part of some Readonly module.But how do I install it? Preferably using the Arch package manager?

View 10 Replies View Related

Programming :: Difficulties Running Commands In Shells From Perl?

Jun 23, 2010

I'm getting something(s) wrong, trying to run commands (both simple and piped) in shells from Perl programs. The ultimate objective is to set up "copy X selection to clipboard" from urxvt but apparently simple debugging statements are not working.Here's the Perl, taken from here and modified to use xclip instead of xsel and with debugging added, shown in green

Code:
#! /usr/bin/perl
sub on_sel_grab {

[code]....

View 5 Replies View Related

Programming :: Talented Coder To Program Bash / Perl App That Plays SWF On HTML Page?

Feb 10, 2011

Everyone knows that it is like impossible to use mplayer to watch an *.html file. OK.

For instance here is a cool example of lot of streaming for firefox
http://watchtvlivestreaming.com/tvlive/b5499

Code...

Anyone is there a talented bright coder, coming from hell -because it is really difficult, to make such console program ?

View 1 Replies View Related

Programming :: Perl About System Command / Fails If The Standard Shell Is Dash And Not Bash?

Jun 30, 2011

I am trying to fix a perl script, and I really suck at perl. But I think this problem will be easy for people who know it.

The problem is, I have an old setup script someone wrote many years ago. It fails if the standard shell is dash and not bash. The only way I've gotten it to work is to point /bin/sh to bash. I looked thru the script and it uses "system" many places, and I think that's the problem.

I searched for it and found this link:url

My plan is to include this function:

Code:
sub system_bash {
my @args = ( "bash", "-c", shift );
system(@args);
}
Then I could simply change all calls to system into system_bash and it should work?

The parameter to the system calls is usually some variable. What if the parameter is a list already? Do I need to test for it somehow, and if it's a list, prepend "bash" and "-c" to the list? How do I do that?

In the script there are lots of places like this:

my $error = system($cmd);
if ($error) {
die/warn "some error message";
}

Shouldn't there be a return in the system_bash function?

View 8 Replies View Related

Programming :: Bash/Perl Script - Provide List Of Hosts To Choose From And Ssh To Chosen Host?

Apr 6, 2010

I'm not sure if this is best done in Perl or Bash. I'm thinking surely someone else has created something close to what I'm looking for. The results of the script would be that someone would kick off "linux_hosts.sh" r whatever you want to call it, then a top "folder" of options (with hosts contained within each of these top menu choices), then, based on which number corresponds to that top level, they're presented with a set of linux hosts that are relevant to that top level name. Example:

$ linux_hosts.sh
1. VMware hosts 4. Private Domain
2. ESX servers 5. Red Hat boxes

[code]...

View 4 Replies View Related

Programming :: Perl - Counting Files With File - Find

Dec 20, 2010

So this is my code:

Code:

Modification of code I found here. It works, but I don't really know why.

Q1: Why is each filter hit counted only when the conditional is not true?

Q2: I've tried taking the file type, (.old), and put it into a variable for better usability, but then the script fails.

View 14 Replies View Related

Programming :: Sed Running Under Bash - Getting Error

Jul 18, 2010

~$ sed s/^bb/bbbbbb/ foo1.txt
~$ sed: -e expression #1, char 3: unterminated s command
~$
Where 'b' stands for space. What is the error here? Sed is running under bash.

View 6 Replies View Related

Programming :: BASH - Can't Check If XScreenSaver Is Running

Feb 26, 2011

I'm having trouble trying to make a script. What I want to do is check if xScreenSaver is running in my user account. If not, run it. If it's running, kill it.

So this is the script I've made:

Code:

The problem is that I've echoed the output of $(pgrep -u $(whoami) xscreensaver) and it always seems to add 4 numbers to the pid, even if the pid doesn't exist. What do I mean by "doesn't exist"? That no xscreensaver is running in my user, and if I run pgrep -u $(whoami) xscreensaver in bash, I get not output, but if I run the command though the script, I get (for instance) 4050. If I run it again, I get 4054, and again 4058... etc. What the hell is going on with that?

View 5 Replies View Related

Programming :: Change Running Path In Bash

Feb 5, 2010

We have a custom app that runs on boot on some older hardware running DSL linux, and their startup manager was quite simple. We purchased some newer Asus eeebox's which run xandros and things are quite stable and run nice with 1 exception.The application only runs from the root (/) location. This box auto logs in as 'user' and there is a /home/user/.kde/Autostart folder where you can stick scripts to run at boot. So I have a start.sh script, and with little bash programming tried things such as;
sudo cd /
sudo /startapp.pl

but the errors start spewing with the basic;can't find data/xyz as it's looking in the local.I thought there was a basic cwd (change working directory) but everything I try just forces the run from that location.Any ideas or suggestions are appreciated, but things like can you change the code, etc. can't be done, so it must be a programming thing. The only other thought I had but not sure, can you do a cronjob with @boot or something, that when the box starts, it can run this job as root and fire off?

View 3 Replies View Related

Programming :: Making Sure Script Is Running In Bash?

Feb 15, 2011

is this a good way of doing it? Shall I use & when starting the new process? Itested in bash and dash.

testbash=$(ps -e | grep $$ | grep bash)
if [ 0 = ${#testbash} ]; then
echo "new process"

[code]...

View 11 Replies View Related

Programming :: Running Bash Script In New Screen?

Feb 16, 2011

I have a bash script that I want to be running on a "clean" screen, but when the script finishes/exits I want to see what was previously on the screen. Any thoughts? The "Clear" command does not enable me to get the information back, and the "Screen" Command runs the program in the original window, so you see nothing until the new screen is exited.

View 4 Replies View Related

Programming :: Running Bash Script Using Java?

Aug 18, 2010

how can i run a bash script script by using java in rhel5... then please reply....i have vary good project in my mind.....

View 2 Replies View Related

Debian Programming :: Running Programs In Parallel In Bash

Jul 22, 2014

I am trying to replicate what is happening on this page under the tcsh shell, but using the bash shell found in Wheezy. Here is the page I am referring to:[URL] The command I am trying to replicate is on page 6 under figure 2.4. The command is "prompt> ./mem &; ./mem &".

I would like to run the same program twice, concurrently, but do not know how. Note that I am not trying to use a bash script, but rather by simply using syntax on the command line.

View 4 Replies View Related

Programming :: Running Script Bash To Fill Files?

Mar 21, 2010

I have around 600 empty text files that I need to add the name of this file as part of the data, I meanfiles from "file1.txt to "file599.txt, all of them empty, and I need to get the name inside the file, so, when I open the file show the name as part the data "file1".these files were created on my web site, I am thinking in a small script in bash

View 5 Replies View Related

Programming :: Simple Bash Script Is Not Running All Of The Commands?

Jun 14, 2010

I am running a simple script that I copied from slug.ceca.utc.edu/docs/2009-3-26-linux-server-health.pdf and edited with the names and paths of my own servers. I don't know much about scripting (re: nothing) but I wanted to try and be efficient in my new role as a Linux Sys Admin. The script was saved to root's home directory and runs as part of root's crontab once a week. The script runs with no problem, but it doesn't actually seem to run all of the commands contained within. It skips some in the middle and the end and I don't know why. The script itself is this:

Code:
#!/in/bash
uname -a > /tmp/server.txt

[code]...

View 5 Replies View Related

Programming :: Find And Replace Script In Bash?

Sep 28, 2010

Im looking for assistance to create a script to find and replace files.Probably best if I give you the background Our server uses a specific application which stores user data, each user data account (a folder on the server) has a file called 'Profile.xml' this file gets updated and replaced about every 30 mins similar to the fashion logrotate works i.e. Profile.xml.1 Profile.xml.2 -> .10

What we experience is that if the application crashes unexpectedly while it is doing its user profile refresh task we end up with sometimes a few hundred Profile.xml files which end up 0kb(should be around 4kb) , and our server see's these as corrupted profiles and will not see them. Our fix is to go back thru and rename the Profile.xml.1 to be Profile.xml (or sometimes up to Profile.xml.5 to Profile.xml) We want a script we can manually run to automate this process The server tree is

/mnt/array1/username/db/Profile.xml
/mnt/array2/username/db/Profile.xml
etc
etc

What we have so far is a script which finds the affected files

find /mnt/ -maxdepth 4 -name Profile.xml -size -1k

This will display a list of affected profiles, and we can append it to a text file with >>output.txt on the end.

if 'pattern' in 'location' equals '0kb' then 'cp' Profile.xml.1 Profile.xml

View 4 Replies View Related

Programming :: Bash Find Files On Time Help?

Mar 11, 2011

I am trying to find a nightly backup if it was successfully copied over, rename it and curl, but it's always passing the check even if the file is older than specified. From the command line it does as it should. Example is here;

Code:
find /backup -type f -mmin +4440 -exec echo "found" {} ;
- nothing returned (good). Then I change the time

[code].....

View 4 Replies View Related

Programming :: Catch User Input While The Bash Script Is Running?

Oct 30, 2010

How do you catch user input while the script is running? Or, how would you make two scripts run at the same time, but use input from one script to the other? The program I'm trying to make, echos text on the screen continuously, but while thats happening, I want the user to be able to input something, so the program can detect the input and display something else. So I thought maybe I could make two scripts run to do each task.

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved