Sponsored Content
Top Forums Shell Programming and Scripting [Solved] Problem insert $1 value into a command Post 302560536 by PatMcDonagh on Friday 30th of September 2011 05:23:07 AM
Old 09-30-2011
Yazu,

thanks for the spot. It helped but the overall problem manifested itself with how the shell was handling ' and " characters.

not long at shell programming but found out that i can turn on debug (set -x) and it dumped the exact command and I then spotted the confusion.

The correct syntax is as follows:

Code:
 
cmd_result=$(/usr/bin/python -c "import time; print time.strftime(\"%d\",time.strptime(""\"${datein}\""", \"%d/%m/%Y\"))" \
 2>/dev/null | wc -l)

Many thanks to Yazu for replying and anyone else for checking the post.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

sed insert command and variable expansion/command substitution

I know this script is crummy, but I was just messing around.. how do I get sed's insert command to allow variable expansion to show the filename? #!/bin/bash filename=`echo $0` /usr/bin/sed '/#include/ { i\ the filename is `$filename` }' $1 exit 0 (8 Replies)
Discussion started by: glev2005
8 Replies

2. AIX

Problem Solved

Generally, most people, I guess, go from 5.3 ML4 Directly to TL 7. So they may never run into this issue. For the rest of us, here is the resolution of my problem in going from ML6 to TL7. Apparently with the change from ML to TL IBM added a "BuildDate Verification" routine into... (1 Reply)
Discussion started by: mrmurdock
1 Replies

3. OS X (Apple)

keyboard problem how to insert --> {} \

I have MACOSX Leoparad and MacBook Pro but I am unable to insert the above letters when I am in terminal any help please? e.g. to insert them I need to press alt+shift+) == } but if I do so pressing alt+shift+) nothing works :( ---------- Post updated at 03:54 AM ---------- Previous update was... (2 Replies)
Discussion started by: c_lady
2 Replies

4. UNIX for Advanced & Expert Users

unix command : how to insert text at the cursor location via command line?

Hi, Well my title isn't very clear I think. So to understand my goal: I have a script "test1" #!/bin/bash xvkbd -text blabla with xbindkeys, I bind F5 key in order it runs my test1 script So when I press F5, test1 runs. I'm under Emacs/Vi and I press F5 in order to have "blabla" be... (0 Replies)
Discussion started by: xib.be
0 Replies

5. UNIX for Dummies Questions & Answers

[Solved] execution problem

Hi I want to make a script . In this script i want to use input file and this input file consist of three numbers in a line for example input file is as below: 919876543210 09876543234567876 98764534245678 aircelmms","aircelweb","aircelwap" 096574235625... (2 Replies)
Discussion started by: esumiba
2 Replies

6. Solaris

Execution problem in shell script while insert into DB

Hi, am facing some problem while inserting a record into a script Please find script below. `sqlplus -s asdf/asdf123 <<eof! set feedback off; set heading off; set verify off; insert into... (2 Replies)
Discussion started by: senkerth
2 Replies

7. UNIX for Advanced & Expert Users

Insert Command Creating Table Locking Problem

Hi, i have a java based tool which does insert operation in a TABLE, and in parallel the same table is used by my C++ code which does select Query. the Table will be always busy, but sometimes the table is getting locked when i try to make an insert, am bit confused whether the lock is... (9 Replies)
Discussion started by: senkerth
9 Replies

8. Shell Programming and Scripting

[Solved] Problem with if-then-else loop

Hi, i have a problem with this script: for i in $(cat list_ip_switch) do if if ; then echo "found ip" else echo "not found ip" fi done cat list_ip_switch 10.155.249.171 10.155.249.172 (3 Replies)
Discussion started by: elilmal
3 Replies

9. UNIX for Dummies Questions & Answers

[Solved] Problem With "xhost +" command-FreeBSD

Does anyone no why "xhost +" would not be working in freebsd? Could it be to do with a certain xorg package not being installed etc.. I am getting error "xhost: command not found" Thanks Anyone (2 Replies)
Discussion started by: Browser
2 Replies

10. Shell Programming and Scripting

[Solved] Insert tabs as delimiter

Hello all, I have an unstructured file with space as delimiter , which I want to structure. The output file should actually have only 5 columns with tab as delimiter. The 4th column can have only 3 values ( biological_process , cellular_component , molecular_function ) Here is how the... (12 Replies)
Discussion started by: ritakadm
12 Replies
STRPTIME(3)						   BSD Library Functions Manual 					       STRPTIME(3)

NAME
strptime -- parse date and time string LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <time.h> char * strptime(const char * restrict buf, const char * restrict format, struct tm * restrict timeptr); #include <time.h> #include <xlocale.h> char * strptime_l(const char * restrict buf, const char * restrict format, struct tm * restrict timeptr, locale_t loc); DESCRIPTION
The strptime() function parses the string in the buffer buf according to the string pointed to by format, and fills in the elements of the structure pointed to by timeptr. The resulting values will be relative to the local time zone. Thus, it can be considered the reverse oper- ation of strftime(3). The strptime_l() function does the same as strptime(), but takes an explicit locale rather than using the current locale. The format string consists of zero or more conversion specifications and ordinary characters. All ordinary characters are matched exactly with the buffer, where white space in the format string will match any amount of white space in the buffer. All conversion specifications are identical to those described in strftime(3). Two-digit year values, including formats %y and %D, are now interpreted as beginning at 1969 per POSIX requirements. Years 69-00 are inter- preted in the 20th century (1969-2000), years 01-68 in the 21st century (2001-2068). The %U and %W format specifiers accept any value within the range 00 to 53. If the format string does not contain enough conversion specifications to completely specify the resulting struct tm, the unspecified members of timeptr are left untouched. For example, if format is ``%H:%M:%S'', only tm_hour, tm_sec and tm_min will be modified. If time relative to today is desired, initialize the timeptr structure with today's date before passing it to strptime(). RETURN VALUES
Upon successful completion, strptime() returns the pointer to the first character in buf that has not been required to satisfy the specified conversions in format. It returns NULL if one of the conversions failed. strptime_l() returns the same values as strptime(). SEE ALSO
date(1), scanf(3), strftime(3) HISTORY
The strptime() function appeared in FreeBSD 3.0. AUTHORS
The strptime() function has been contributed by Powerdog Industries. This man page was written by Jorg Wunsch. BUGS
Both the %e and %l format specifiers may incorrectly scan one too many digits if the intended values comprise only a single digit and that digit is followed immediately by another digit. Both specifiers accept zero-padded values, even though they are both defined as taking unpadded values. The %p format specifier has no effect unless it is parsed after hour-related specifiers. Specifying %l without %p will produce undefined results. Note that 12AM (ante meridiem) is taken as midnight and 12PM (post meridiem) is taken as noon. The %Z format specifier only accepts time zone abbreviations of the local time zone, or the value "GMT". This limitation is because of ambi- guity due to of the over loading of time zone abbreviations. One such example is EST which is both Eastern Standard Time and Eastern Aus- tralia Summer Time. The strptime() function does not correctly handle multibyte characters in the format argument. BSD
October 2, 2014 BSD
All times are GMT -4. The time now is 02:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy