I know that this has a bad title, but I'm not sure how to sum it up well.
(And I'm new to Linux in general, so please excuse any incorrect terminology )
Anyway, I'm trying to create a script that gets whatever folder you're in, and then does a command with that directory as an argument. I guess that it would be easier to show you than explain.
I want it to do a pwd command, and then just get that last folder (ie /home/alberte/study would translate into just study) and then put that on the end of a system command.
Now, I figured that I would be able to do this properly in bash, so I started out with this:
I would then pass this into a text file, look at the top two lines, and if there was text in the second line, it would delete the first line (eventually removing everything except the last folder). But then I realized that you couldn't do this with sed (or at least, I don't think it can). Talking with a friend, he directed me to perl, seeing as it would be easy to do text parsing, so heeding his words, I checked out perl.
Well, now, I can get perl to easily return the last word that was passed into it (ie "script.pl this is a test" would just print out "test"). So I figured that I could just call the perl script from the bash, and then I would be set. So, these are my scripts right now:
Bash
Perl
Well, that really doesn't work. It looks like the Perl script isn't seeing this as arguments, but rather something else.
If any of you could point me in the right direction (even tutorials that feature this would be great), it would be very much appreciated. I've been working on this off and on for a few weeks, and I'd just like to get this done. Thanks for any help that you give in advance.
Alright, I didn't know that there was an easy way to get the folder that you're in, and not the entire path. Thanks a lot for the help. I appreciate it.
Hello,
im having bash script with
while ***
command1 &&
command2 &&
command3 &&
done
i want to ask how i can prevent overloading server, by waiting untill all commands complete? any low resources intensive command like "wait" - i dont know if exist? (2 Replies)
1. The problem statement, all variables and given/known data:
Hello!
I need help with this problem bash shell scripting that basically just reads the data in a tab delimited file and does the following below
1. Read in the data file Survey.txt and assign the column values to variables of... (6 Replies)
shell=ksh,
How could I schedule tasks in shell script INSTEAD OF using the crontab -e functionality?
For example, I want a script to print "Hello World" every 10 seconds (i.e., INTERVAL = 10s) until external termination signal is triggered.
Thanks, (2 Replies)
Hi, I have a question.
I have a file that I need to do two things to.
The first thing I need to do is turn a file with lines before and after a line with the term "Acceptance" into only the "Acceptance" line and every line thereafter. I am using this:
grep -A1000000 "Acceptance" Brown_DL... (2 Replies)
Dear all,
I I want to login to my Linux machine using putty and then run some script from Windows machine.we can do it after loging it and then execute the script by typing it in putty command line screen. but I want to automate it.So whenever I will fire this script,it will do the following... (4 Replies)
Hi all,
I need to execute a script on a remote machine that are connected to the network.The basic requirement is to write a script which will login in remote machine and then execute the other script automatically placed in remote machine.So that I need to execute the remote machine script... (3 Replies)
Scenario:
I have two PCs (named as A & B) which would send some traps to my third PC (named as C).
In PC C, I have to write a shell script such that it should accept the datas from both the PC-A & B parallely.
So my question is, is it possible to have two different child threads/tasks... (2 Replies)
Hi All,
Can I automate a script when some one trying to 'vi' (open) a file.
For Example, I am having a file named 'SecuredShell.sh'.
when a user types " vi SecuredShell.sh " in unix command prompt a script named secure.sh needs to be automated.
Can this be possible. if Yes please guide... (2 Replies)
Hi All,
./procdure.ksh which opens the below the menu, I want to build a script which will press 4 and run the Sector Data Automatically (instead of pressing option 4 manually)
Is there any way for this, please let me know...
1) FX Rates MDU 9) Fidessa Cash... (7 Replies)
I am trying to use a here document to automate testing a perl script however when the perl script hits a system(perl subscript.pl) call, input is no longer entered into this subscript.
here is my script
$ cat test.sh
#ksh
for testcase
do
program <<-EOF | tee -a funcscnlog.log
y... (3 Replies)