General :: Pass Shell Parameters To Awk Does Not Work?
Jun 16, 2011Why does this work
Code:
for myfile in `find . -name "R*VER" -mtime +1`
do
[code]...
Why does this work
Code:
for myfile in `find . -name "R*VER" -mtime +1`
do
[code]...
I am new to bash scripting (not programming in general).
I am writing a bash script that will run a Python script I have written.
I want to be able to do the following:
Pass parameters to the bash script via the cronjob (so I can have two cron jobs) one to be run with parameter 'foobar', and the other 'foo'
switch based on the parameter passed to the bash script (by switching, I mean an if/else based on the paramter passed to the bash script).
I have a Python script that I run which needs to execute under a special environment, so I would run the program like so from my working directory (~/project/src):
python manage.py shell
This opens up an interactive shell for me to start typing my own commands.I have another set of administrative activities that I would like to house in another directory (~/project/admin). The manage.py is really finicky about running from the working directory. So, to make this whole thing work, I made a script which starts off like so:
#!/usr/bin/python ../src/manage.py shell
There are a couple problems with this. The first is that it doesn't work:
/usr/bin/python: can't open file '"/../src/manage.py" shell': [Errno 2] No such file or directory
How do you specify multiple parameters to the interpreter?How do I change the working directory?
How do I pass file names as parameters to the shell through a script? I have installed 'wipe' from the repos and it is a shell based app. so I made a shellscript and put it in my script folder.
the normal usage of wipe is 'wipe -q /path/to/file' so if I were to make a shell script, right click on the file in question, and run the script on it, how to I permit the shell to wipe that file only, in other words pass it as a parameter. I think on windows it was the use of %1, such as. 'wipe -q %1' for example, which was simple enough. how to I achieve this with bash?
Old Toshiba laptop model A30 -- tried various installs 8.04/9.04/9.10. They all hung trying to boot the install disks after the initial few screens. Finally, I got 9.10 to install, dual booting XP and 9.10 by choosing F6 from the initial menu, and putting an X beside:
ACPI=off
noapic
nolapc
edd=on
nodmaid
and then hitting escape.But, after the install, I couldn't boot 9.10 from grub as it hangs after about 30 seconds of trying. The live CD would not work without the above parameters being set as described above, but does work with them set! I need those same parameters passed to grub at 9.10 boot time, but I can't figure out how to do that. I've had many successful installs of Ubuntu across a number of desktops and laptops, but I never had to deal with the guts of grub before. It all just worked.
what I am trying to do but I am not sure exactly how to do it. I want to write a shell script that will replace certain values in a file with environment specific information that it pulls from a parameters file. The paramaters file looks like the following...
[dev]
ip=10.15.109.41
name=dev1.mydomain.com
[code]...
myscript [-a a-arg] [-c c-arg] [-b] [-e] somedirectory
Given that I want my shell script be invoked at the command line using the above parameters - where [these brackets] denote that they are optional - what is the best method to parse them?
I set up a bridge device but I can not figure out how to pass parameters into the ifcfg-vmbr0 in particular I need to pass:
maxage
ageing
fd and stp seems to be passed by DELAY=0 and STP=on the others? I have not found anything in the post, tips, docs how could I do?
I am calling a URL from shell script and passing few argumants,Here i have to pass file content as one argument.How can i pass file content through URL.
eg:
content=`cat /Users/test1.txt`
open http://localhost:8080?filecontent=$content
[code],...
1. What file do i have to edit in order to include /usr/local/bin in the class path (ie. I put an executable in /usr/local/bin and when I try to execute it, it says the command cannot be found, etc.) EDIT: Solved, just didn't set PATH correctly. EDIT: New problem. When I try to execute a program in /usr/local/bin, it says "fopen: john.ini: File not found" Yet when i cd to /usr/local/bin, it doesn't say that. What would cause this?
2. Once I get my system setup the way i like it, how would i go about making it into a bootable CD/DVD?
3. How would I pass arguments from a shell script to a program?
I want to pass ip address,port address and some parameters from command line using python script.The ip address and port address for establishing socket connection and remaining parameters to execute different connection.
View 1 Replies View RelatedI am setting up my test / development machine with the following scenario in mind : I boot the machine and then select one of a number ( e.g. 3 ) boot options in Grub ( Normally "OpenSuse", "Safe Mode" etc., but in this case "System Restore Dev.", "System Restore Test" ). The only difference between these options are the settings ( e.g. "vga=378" ) in these cases something like "distro=dev" / "distro=test".
In a script run on the booted system I can extract the value of the "distro" parameter ( in this case "test" ) and use it as input for a command line tool. Meaning that name entered as the value for the "distro" parameter is used for loading a file when the system is up and running. The command line tool then restores the partition with the contents of the file and reboots the system.Now, my problem is this : How to I access the Grub arguments? Code snippets ( in shell scripting or python preferbly ) are more than welcome.
Some may recall I recently gave up on bash, rather than give up my programming style.Surely I will have reason to return but that's another story. My little issue now:I am debugging a new [Korn] shell script. I have a function that performs a specialized match on a string and I see that I am able to call that function with no problem, with both of it parameters. The function does not do any print or echo command - it uses "return" for a TRUE (0) of FALSE (1), as is the shell exit code convention. Thus, I have the following test:
Code:
if [[ match_except_release ${PATH_DIR[$LC]} bin ]]
then
[code]....
Code...
I am somewhat confident that there is a neater way.
Question: Does anybody know the answer?
I have the following code :
Code:
E_BADARGS=65
if [ $# -ne 2 ] ; then
[code]...
I have some messy code that I wrote a while back and I am trying to organize it. The program opens xpaint and uses xwit and xte to draw packman and so on. I want to split it all up I am going to add more to it. Basically like i would want drawing packman in one function i guess you could call it and then coloring him or the background in another
<code>
#!/bin/bash
pkill xpaint
res=`xwininfo -root | grep geom | sed -e 's/^.*try ([0-9][0-9]*x[0-9][0-9]*)+.*$/1/'`
Xoriginal=`echo $res | cut -d 'x' -f 1`
Yoriginal=`echo $res | cut -d 'x' -f 2`
X=`echo "($Xoriginal/2)-400" | bc `
Y=`echo "$Yoriginal/2" | bc `
#t=$(($Y/2))
bob=`echo "$Y/2" |bc `
echo $X
echo $Y
/usr/bin/xpaint -size "$Xoriginal"x"$Yoriginal" -popped &
sleep 4
paintersMom=`xwit -all -print | grep XP | cut -d ":" -f 1`
canvasWin=`xwit -all -print | grep Untitled | cut -d ":" -f 1`
#toolres=`xwininfo -id $paintersmom | grep geom | sed -e 's/^.*try ([0-9][0-9]*x[0-9][0-9]*)+.*$/1/'`
#canres=`xwininfo -id $canvasWin | grep geom | sed -e 's/^.*try ([0-9][0-9]*x[0-9][0-9]*)+.*$/1/'`
#echo $paintersMom
xwit -id $paintersMom -move 0 0
xwit -id $canvasWin -move 0 0
xwit -root -warp "$X" "$Y"
sleep 4
for((i=45; i < 315; i++))
do
xte 'mousedown 1'
ang=`./deg2rad $i`
movex=`echo "$X+$bob*c($ang)" | bc -l`
movey=`echo "$Y+$bob*s($ang)" | bc -l`
xwit -root -warp "$movex" "$movey"
done
xwit -root -warp "$X" "$Y"
xte 'mouseup 1'
#xwit -id $paintersMom -focus -raise
#sleep 1
#xwit -id $paintersMom -warp 30 390 #// fill in command on tool bar
#sleep 1
#xte 'mouseclick 1'
#sleep 1
#xwit -id $canvasWin -warp 221 40 #// color selection
#sleep 1
#xte 'mouseclick 1'
#sleep 1
#xwit -id $canvasWin -warp "$(($X-150))" "$Y" #//location on pac man
#sleep 1
#xte 'mouseclick 1'
#sleep 1
#xwit -id $canvasWin -warp 62 44 #// selecting color black
#sleep 1
#xte 'mouseclick 1'
#sleep 1
#xwit -root -warp 62 120 #// selecting back to canvas
#sleep 1
#xte 'mouseclick 1' #// color canvas black
#sleep 1
#xwit -id $paintersMom -focus -raise
#xwit -id $paintersMom -warp 27 108 #//click back to pencil
#sleep 1
#xte 'mouseclick 1'
#sleep 1
</code>
Here for example $paintersmom is would be in the drawing of pacman but I would also want to use it when I colored him in.. but I would want both processes in a different shell script.
I want to have a choice or more preferable pass shell as command line argument when I ssh to an linux account.i.e. If John logs in to account "zzz" on server "abc", by default definition of account "zzz" n server "abc" he get csh.But Sally desires that when she logs in to account "zzz" on server "abc", she needs the login shell to be ksh,and Rick wants bash when he logs in to account "zzz" on server "abc".What is the most non-intrusive / easiest way to achieve this? Each user can set their preference on ssh command line or create a simple alias by each shell, but not sure how to do this.
View 6 Replies View RelatedIf I pass to my shell environment as a regular user will it apply to builds ran under sudo?I posted a thread similar to this regarding a build with TOR; however, this is applicable to all programs.
View 6 Replies View RelatedI'm new to UNIX scripting; I�m stuck with the following I have an Oracle SQL script that takes three parameters
1- File Name
2- File Path
3- File creation date
Under UNIX I have a folder where files will be placed frequently and I need to upload those files to Oracle, what I need is a UNIX script that can do the following
Loop through Directory "/home/applmgr/snktmp"
Picks only files
Pass the file name to parameter &1
[code]....
Is the above possible? I already knows how to call the Oracle Script from UNIX Im only stuck on writing the UNIX part where it List the files attribute(name,path,date) and store them to parameters ,Looping until the last file in the directory If the above is not possible,then how can I create the below from the command line
Filename{concatenation Mark}filePath{concatenation Mark}creationdate
Filename{concatenation Mark}filePath{concatenation Mark}creationdate
Filename{concatenation Mark}filePath{concatenation Mark}creationdate
Filename{concatenation Mark}filePath{concatenation Mark}creationdate
I need to mount a windows share on my OpenSUSE 11.3. I get it using the mount.cifs command (by itself or using cifstab), but only root can rw file. I try the uid/gid parameters (also using forceuid) and the file_mode/dir_mode parameters, but I get the same behavior: all files and directory with rwxr-xr-x permissions and root/root (user/group). I read the whole section FILE AND DIRECTORY OWNERSHIP AND PERMISSIONS in man mount.cifs but nothing works.
View 9 Replies View RelatedI have very annoying problem with USB passthrough in Centos 6. My XLM guest file to forward USB ( I checked this manually and using virt manager) :
<hostdev mode='subsystem' type='usb' managed='yes'>
<source>
<vendor id='0x0d7a'/>
<product id='0x0001'/>
</source>
</hostdev>
[Code]...
Someone gave me a script that would tar then gzip my music directory, as well as remove the previous days backup. I have it set up in crontab, but it appears to have stopped working the last couple days, so i tried running it manually. Below is the script and the output I got. Any ideas why its failing now? I don't think anything changed on the server, maybe someone installed updates but idk why that would affect this.
Here's the musicbackup.sh script code...
When I choose the network password type WPA for example it doesn't work. Currently on my Dell Inspiron 1750 64 Bit am dual booting Ubuntu and Linux mint. I have the driver installed for the wifi card (Broadcom 802.11 Linux STA wireless driver). Installed on both Ubuntu and Linux Mint, I don't know if there the exact same but very similar if not. So now I will get to the problem. When I click the wifi network button (Ubuntu is top right on panel, Linux Mint is bottom right on panel) and click the network I want to join the pass key box pops up.
But when I click the down arrow (WPA & WPA2 Personel selected by default) it just highlights the default selection, already stated. The weird thing is it does it for both Linux Mint and Ubuntu now. See, it didn't do that before I installed Linux mint and just had ubuntu. Wish I could post a screen shot but it would be a hassle without having the computer with Internet. I tried changing themes still does the same thing. Right when I installed the driver it worked fine with my home internet where I installed it using a ehternet cable. But now that I am trying to connect to a new network and it does this.
Since moving from centos 5.6 to fedora 15 a week ago I have been unable to get Last Pass firefox addon to work correctly. Those of you familiar to last pass will probably have seen the error message before in a variety of situations, namely "An error occurred while attempting to contact the server. Please check your internet connection." This error appears as soon as you log in (which it does manage to do) but instantly loses authentication - seems like the cookie expires almost instantly and therefore all saved sites/passwords require re-authentication with LP to use.
No network configuration has altered since the OS change, but F15 comes with firefox 4 rather than 3.6.x in centos. I know the last pass plugin should work with FF4 and have read suggestions about SSL/TLS version settings (which are 3.0 and 1.0 respectively) and disabling SELinx. Neither of these have made any difference.
I am using a server where i need to login twice. The first time i login as my boxname and pass. The 2nd login is 'root' so i can access the content of the box (i dont understand it but that hasnt stopped me from using it as normal).Now i like a GUI so i can browse files easier and drag and drop multiple files instead of using the command line. WinSCP doesnt work as it locks up. I suspect its because there is a prompt to log in again.
What can i use to drag & drop files?
How to use CHMOD in linux? When I try to delete a file/folder, permission is denied. What exact params must I give for chmod here? This is what I need to do. Execute a command ./build.mips , but I get permission denied error.
kirti@sgf:/disk/go$./build.mips
-bash: ./build.mips: Permission denied
I've a script that it's invoked with n-variable parameters. Here's an examples:
Code:
./myprogram.sh inputdir FIELD1 FIELD2 ... FIELDN outputfile In the script I would like to get the FIELD names that were passed.
I have the following bash script:
Code:
Which has the name 'extractemails.sh' and works just fine.
However, i whish to be able to give the url (or any other url) as a parameter when i run the script like this: $ extractemails.sh [url]
What should i change in my code? i have never tried passing parameters to scripts before.
the problem is i am changing the parameters in main.cf file but postfix is not accepting them. its still inheriting my system's host name and domain
here is my configuration
my main.cf file
myhostname = mail.example.com
mydomain = example.com
myorigin = $domain
[Code].....
Nothing is accepted. I have test this on CentOS 5.5 and Fedora 14 both have the same result.
I am reading a tool manual and it instructs to use such a command:
Code:
Especially, what does the 'sort' parameters and awk do?