The output I am expecting is '*****'. But It is showing me the available files of current directory. When I run the command
head -1 /tmp/tuxob.lst | awk '{print $NF}
from unix prompt - I can see the output as '*****'
Please advise, what am I doing wrong?
Last edited by Scott; 08-16-2010 at 06:20 AM..
Reason: Please use code tags
If above is the script, then how do I put if conditions. i.e. If $input = '*****' do something. Because on putting $input displays files of current directory being expanded to echo *
edit by bakunin: i added the CODE-Tags you probably have forgotten.
If above is the script, then how do I put if conditions. i.e. If $input = '*****' do something.
First off, you don't need any if-contructions. You should quote your variables regardless of them containing something which has to be quoted or not, because even if said variables normally don't have a content which has to be quoted they might do so occasionally and a script shouldn't work "most of the times", but always.
In programming caution sometimes helps but never hurts, so be as cautious as possible.
Secondly, you shouldn't use the backticks any more: they are supported only for backwards compatibility purposes. Use the "$(...)" instead:
Thirdly, the command only fills a variable with some content - in this case some asterisks. No shell expansion is done here. It is probably done when you subsequently try to display the variables contents. THIS is the place where you have to protect your variable from being expanded by the shell:
Btw.: if the only thing you want to do is to display it, you don't even need the variable:
Hi everyone
I have a problem with my script
If I try directly this command
/usr/bin/nice -n 19 mysqldump -u root --password="******" wiki_schneider -c | nice -n 19 gzip -9 > /point_de_montage/$(date '+%Y%m%d')-wiki-db.sql.gz
It works
But if I simply add this command in a script and... (8 Replies)
Hello all,
Here is what my bash script does: sums number columns, saves the tot in new column, outputs if tot >= threshold val:
> cat getnon0file.sh
#!/bin/bash
this="getnon0file.sh"
USAGE=$this"
InFile="xyz.38"
Min="0.05"
#
awk '{sum=0; for(n=2; n<=NF; n++){sum+=$n};... (4 Replies)
I notice that su - user (note with dash) brings in more of the user's environment than does su - user -c 'command'. For example, if root does an su - user, and types "umask" to the prompt, one umask is displayed; yet, if instead the command is su - user -c 'umask', the value is different. I thought... (2 Replies)
Hi have a script which transferers from Microsoft server to Linux box.
The scripts(ksh) is on Linux box.
If I run script from terminal, it transfers files to directory. Where as If
I run script from CRON. It does not.
Here is the log of both:
Terminal execution log:... (2 Replies)
Gurus,
I have written a shell script to backup a database and applications. This is how the script works:
1. As applications user (say applmgr), the main backup script, say backup.sh, is kicked off.
2. backup.sh does ssh to oracle user and kicks off the database backup using nohup and... (1 Reply)
hi
i have file extentioned with test.vbs. i am able to run this file n execute through command promt but i dont know how to run in shell script
example:
file name is test.vbs which contains
strSoundFile = "C:\windows\Media\Notify.wav"
Set objShell = CreateObject("Wscript.Shell")
strCommand... (5 Replies)
Hi,
I have an awk script which performs simple operations of variable assignments and finally printing the variables in custom form.
BEGIN {FS=OFS="\n"}
{
v1=substr($0,1,15)
v2=substr($0,16,200)
v3=substr($0,216,20)
print v1 "|" v2 "|" v3
}
The input file being processed... (2 Replies)
Hey all,
Just wanted to get some input on a script I am using to import files into a MySQL database.
The process is pretty simple: my main server exports these files and FTPs them. I have a script that FTPs them to the machine running that runs this script. The FTP script runs without issue... (2 Replies)
I hope someone can shed any light on this mystery.
I am trying to run the following command:
su userID -c
remsh server -l userid -n "awk -F^ '\$4 == \"SMITH\"' /tmp/infromational/version74b/LIVE/TEMPORARY/ABCfiles/HLC_Database_File.bat|head -1" > /tmp/variant/45BV32/var/store13.logfnd
I... (15 Replies)
I am writing a menu script and one of the options is to access a Command Prompt and return to the menu via CTRL-D. I have tried using a loop and echoing the PS1 value, then using read to assign whatever is entered into a variable, then executing the value of that variable as a command using
.... (1 Reply)