Call a Perl script within a bash script and store the ouput in a .txt file
I'm attempting to write a bash script that will create a network between virtual machines. It accepts three arguments: an RSpec that describes the network topology, and two list of machines (servers and clients).
I have a (working) Perl script that I want to call. This Perl script takes an RSpec and finds the machine names and/or IP addresses, and prints them to the STDOUT.
What I want to happen is for the bash script to call the perl script (which is in a subdirectory), and pipe the output to a .txt file. Right now, I keep getting an error saying the perl script doesn't exist, though I am giving it the full pathname.
This is the bash script:
The error I'm getting is:
If it helps any, I'm using ubuntu on a VirtualBox VM (physical machine is a MacBook Pro). (The starred out text was a folder containing my name...)
Any and all help (and explanations, too) would be greatly appreciated. I'm relatively new to both perl and bash (only been using these languages for a few months).
I am aware that there are other threads dealing with similar topics, but I could not find one that suited this problem specifically.
Thank you, but this did not work. The error is exactly the same as before.
Yeah. On many shells, cd ~ is treated as a synonym for cd $HOME, however cd ~logname (where logname is your login name) should work.
But the real issue is that $HOME has been set incorrectly; it should ALWAYS be an absolute pathname.
It looks like you may have accidentally removed the leading "/" from $HOME. If you log out and log back in and $HOME still does not start with a "/", you'll need to dig through your shell's initialization files and correct the line that sets HOME.
Until you find the problem, assuming your login name is mecaka, the following should get your current shell execution environment back to a reasonable state:
Yeah. On many shells, cd ~ is treated as a synonym for cd $HOME, however cd ~logname (where logname is your login name) should work.
But the real issue is that $HOME has been set incorrectly; it should ALWAYS be an absolute pathname.
It looks like you may have accidentally removed the leading "/" from $HOME. If you log out and log back in and $HOME still does not start with a "/", you'll need to dig through your shell's initialization files and correct the line that sets HOME.
Until you find the problem, assuming your login name is mecaka, the following should get your current shell execution environment back to a reasonable state:
I just went back and read my original post. I am not posting this from the browser on my VM, so I could not copy and paste... There is a backslash before home, and there has been the whole time. I apologize for this confusion. I will correct this in the original.
However, if this was not the issue, what is? The PWD is "/home/*****/Documents" (assuming this helps any...)
I must add, I don't know much about the behind-the-scenes workings of programming. There might be something quote-en-qoute "obvious" that I wouldn't have caught.
Sometimes, 'file not found' can mean it can't find a library. Check that perl runs properly when you run it by hand.
But I suspect it really means what it says -- the file really, genuinely isn't there. Look very closely for typos.
Wow... Yeah, the actual filename was "getIDs.plx", my code said "getIds.plx", and the code I posted didn't have the 'g'... Thanks for pointing that out!
Hi, I am complete new to C programming and shell scripting. I just wrote a simple C code to calculate integral using trapezoid rule. I am prompting user to pass me No. of equally spaced points , N , upper and lower limit. My code looks as follows so far:
#include<stdio.h>
#include<string.h>... (2 Replies)
Hi,
I need help in writing a shell script which can read data from a text file (Cancel_ID.txt) and then calls sqlplus session (Cancel.sql) with the first line parameter of the text file ("0322600453") till all rows are not completed.
... (4 Replies)
Hi All,
Just have a requirement, I am executing a bash shell script, my requirement is to catch the pid and job name to a txt file in the same directory, is there anyway to do it? please help me out.
Regards
Rahul
---------- Post updated at 08:42 AM ---------- Previous update was at... (2 Replies)
In a bash script, one can call a perl command in the following manner, where "myperlcommand" is a perl command.
perl -e 'myperlcommand(arguments)'
perl -e 'print("UUUU"x4)'
Now, how can one call a bash command from within a perl script? (Suppose that mybashcommand is a bash... (1 Reply)
Ok, don't ask me why, but all calls to perl must be called by a shell script. Its really not ideal, but its what I have to work with.
Calling it isnt the issue, its passing in the arguments.
I have about 1000 perl scripts to call by a shell script. Right now, I'm executing the shell script... (3 Replies)
I am writing a script to write to and a sort txt file. After I sort the file I want to add 2 to each line of the file. My script thus far is
#!/bin/bash
cat > /ramdisk/home/stux/unsortedints.out
COUNT=0
FILE =/ramdisk/home/stux/unsortedints.out
for i in {1..100}
do
NUMBER = $
echo $NUMBER... (3 Replies)
Hi
I m new to perl. I m trying to write a perl script that calls a bash script; does anyone have a script already that they can provide or help me out? Thanks a lot. (2 Replies)
Novice to perl here.
I have created a simple web page in perl, with only one submit button. I would like to execute a bash script on the same server when this button is clicked on.
Is this possible in perl? I have spent a few days researching this and am unable to find any useful information.... (0 Replies)
hi,,
i have perl scipt with line :
system('./try.sh $t $d $m');
in shell scipt try.sh i have the line:
echo $1
its not printing value of $t that i hav passed..y is it so..i am running it from apache web server (2 Replies)
Hi
I have this code, and i want work with a ls -shalR output in .txt
What i need read to do this??
Where start?
#!/usr/bin/perl
# Allrights- A perl tool for making backups of file permissions
# Copyright (C) 2005 Norbert Klein <norbert@acodedb.com>
# This program is free... (1 Reply)